EdgeFedSim: A Simulator for Federated Edge-Cloud Environments
EdgeFedSim is a Python-based simulation framework for modeling and evaluating workflow scheduling strategies in a federated edge-cloud computing environment. It is built upon the simpy discrete-event simulation library and allows for detailed modeling of infrastructure, applications, and scheduling policies.
The simulator is designed to assess the performance of different schedulers based on key metrics such as makespan, energy consumption, cost, and scheduling latency.
Features
- Federated Infrastructure Model: Simulates a hierarchical environment composed of multiple edge and cloud clusters.
- Detailed Resource Modeling: Nodes are defined by CPU and memory capacity, with distinct power consumption models (idle and max) and hourly costs.
- Realistic Network Simulation: Models network latency and bandwidth for both intra-cluster (within a cluster) and inter-cluster (between clusters) communication.
- Complex Application Workflows: Applications are modeled as Directed Acyclic Graphs (DAGs) of tasks, with dependencies and data transfer sizes between them.
- Extensible Scheduler Architecture: Provides a base scheduler class to easily implement and plug in new scheduling algorithms.
- Configurable Experiments: All simulation parameters, from infrastructure setup to workflow characteristics, are managed through a central
config.yamlfile. - Built-in Schedulers for Comparison: Includes several implemented schedulers:
- Cerebrum: A hierarchical scheduler that decomposes workflows and uses policy-based (performance, energy, cost, balanced) utility functions for placement.
- Network-Aware Heuristic: A scheduler that prioritizes placing tasks on the same node as their largest data dependency.
- FL-Block: A variant of the network-aware scheduler that introduces a fixed latency, mimicking federated learning cycles.
- Comprehensive Metrics Reporting: Automatically calculates and displays key performance indicators (KPIs) like average workflow makespan, energy usage (kJ), financial cost ($), and scheduling decision latency (ms).
Installation
-
Clone the repository:
git clone https://github.com/ahmadpanah/EdgeFedSim.git cd EdgeFedSim
-
Install the required Python packages: It is recommended to use a virtual environment.
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` pip install -r requirements.txt
Usage
The main entry point for running simulations is main.py. By default, it runs an experiment comparing the built-in schedulers and prints a summary of the results.
To run the simulation, execute the following command:
python main.py
The script will output the results for each scheduler and finish with an overall comparison table.
--- Overall Comparison ---
+---------------------------+--------------------+-------------------+--------------+--------------------+
| Scheduler | Avg Makespan (s) | Avg Energy (kJ) | Avg Cost ($) | Avg Latency (ms) |
+===========================+====================+===================+==============+====================+
| Network-Aware Heuristic | 129.55 | 3881.33 | $21.78 | 0.15 |
| FL-Block | 129.56 | 3881.33 | $21.78 | 0.14 |
| Cerebrum (balanced) | 97.94 | 3311.11 | $13.43 | 1.54 |
| Cerebrum (performance) | 97.94 | 3311.11 | $13.43 | 1.49 |
| Cerebrum (energy) | 97.94 | 3311.11 | $13.43 | 1.49 |
| Cerebrum (cost) | 97.94 | 3311.11 | $13.43 | 1.49 |
+---------------------------+--------------------+-------------------+--------------+--------------------+
(Note: Results may vary based on the configuration.)
Configuration
The simulation behavior is controlled by the config.yaml file. Here you can adjust parameters for the infrastructure, workflows, and schedulers.
Key Configuration Parameters:
-
infrastructure:node_configs: Defines CPU and memory capacities for different node types (e.g.,small_edge,large_cloud).cluster_configs: Specifies the composition of each cluster type (e.g., number of nodes and their type).network_*: Sets latency (ms) and bandwidth (Mbps) for intra- and inter-cluster networks.*_node_cost_per_hour: Defines the operational cost for edge and cloud nodes.
-
workflow:num_workflows: The total number of workflows to simulate.min_tasks,max_tasks: The range for the number of tasks in each workflow.task_*_range: Defines the range for CPU/memory requirements, runtime, and data sizes for tasks.
-
scheduler:cerebrum_policy_weights: Sets the weights for performance, energy, and cost for the differentCerebrumscheduler policies.fl_block_latency: The additional scheduling latency for theFL-Blockscheduler.
Project Structure
EdgeFedSim/
│
├── .github/workflows/ # GitHub Actions for CI/CD
│
├── examples/schedulers/ # Example implementations of custom schedulers
│ ├── LeastLoadedScheduler.py
│ ├── Network-AwareScheduler.py
│ └── RandomScheduler.py
│
├── application.py # Defines Task and Workflow classes
├── config.yaml # Central configuration file for the simulation
├── infrastructure.py # Defines Federation, Cluster, Node, and Network classes
├── main.py # Main script to run experiments
├── requirements.txt # Python package dependencies
├── scheduler.py # Implementation of the core scheduling algorithms
├── simulation.py # Core simulation logic orchestrating the environment
└── utils.py # Utility functions and configuration loader
How to Extend
Adding a New Scheduler
You can easily add your own custom scheduler to the framework:
- Create a new Python file in the
examples/schedulers/directory or another location. - Define a class that inherits from
AbstractScheduler(fromedgefedsim/schedulers/abstract_scheduler.py). - Implement the
schedulemethod as required by your logic. See the provided examples for the expected signature. - Import your new scheduler in
main.pyand add it to the experiment runs.
Here is a simple example of a random scheduler:
# examples/schedulers/RandomScheduler.py
import random
from edgefedsim.schedulers.abstract_scheduler import AbstractScheduler # Or import BaseScheduler
class RandomScheduler(AbstractScheduler):
def schedule(self, current_time, ready_tasks, federation_state):
placements = []
all_nodes = list(federation_state.nodes.values())
for task in ready_tasks:
suitable_nodes = [
node for node in all_nodes
if node.resources["cpu_mips"] >= task.requirements["cpu_mips"]
]
if suitable_nodes:
selected_node = random.choice(suitable_nodes)
placements.append((task, selected_node))
return placements
Dependencies
The project relies on the following Python libraries:
simpy: For discrete-event simulation.networkx: For creating and managing DAG-based workflows.numpy: For numerical operations and random number generation.python-louvain: For community detection in the Cerebrum scheduler.tabulate: For printing formatted result tables.pyyaml: For parsing theconfig.yamlfile.
License
This project is distributed under the MIT License. See the LICENSE file for more details.
Metadata
Release files for edgefedsim 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| edgefedsim-0.1.0.tar.gz | 16.0 kB | Without provenance | Details for edgefedsim-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| edgefedsim-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for edgefedsim-0.1.0-py3-none-any.whl |
Total release size: 31.1 kB
Release files / edgefedsim-0.1.0.tar.gz
| Download URL | edgefedsim-0.1.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db2e3271b2134e5f4fe692d8d44acba66dec463cc970590aad1544835a83a7ab
|
|
BLAKE2b-256 checksum How to use checksums |
0855d37f5d7e39aa22ad9665323c5a5df7c4d1911130ce23f0b76d4d028495ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Release files / edgefedsim-0.1.0-py3-none-any.whl
| Download URL | edgefedsim-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cce2dbe8ca8342cd27c02759421f59dd607ebb116572bd67e44c32e885494bf3
|
|
BLAKE2b-256 checksum How to use checksums |
b95e448e4ac36ec53c791977158b81466f934bef154defd33672ca0d9a1a7a9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for edgefedsim 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.