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.
config.yaml
file.pip install edgefedsim
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
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.)
The simulation behavior is controlled by the config.yaml
file. Here you can adjust parameters for the infrastructure, workflows, and schedulers.
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 different Cerebrum
scheduler policies.fl_block_latency
: The additional scheduling latency for the FL-Block
scheduler.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
You can easily add your own custom scheduler to the framework:
examples/schedulers/
directory or another location.AbstractScheduler
(from edgefedsim/schedulers/abstract_scheduler.py
).schedule
method as required by your logic. See the provided examples for the expected signature.main.py
and 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
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 the config.yaml
file.This project is distributed under the MIT License. See the LICENSE
file for more details.