Container Simulation Framework is a Docker Swarm-like simulation tool built with SimPy. It allows users to simulate the behavior of Nodes and Containers, track resource utilization, and visualize system performance over time.
This framework enables users to:
- Define Nodes (Physical or Virtual Machines) with limited resources (CPU, RAM, Disk, Bandwidth).
- Deploy multiple Containers inside Nodes with dynamic workloads.
- Apply fluctuation effects on resource consumption.
- Simulate workload requests with different delay, duration, and priority.
- Monitor and visualize CPU, RAM, Disk, and Bandwidth utilization.
- Use First-Fit Load Balancing to allocate workloads efficiently.
- Enable or disable resource reservations for smarter workload scheduling.
- Monitoring and data collection of an existing containerized system.
Below is the high-level architecture illustrating the framework's structure and its components:
git clone https://github.com/milanbalazs/ContSysSim
cd ContSysSim./tools/create_venv.shThis script creates a Python virtual environment (
simulation_venv), installs the required dependencies, and container-simulation package.
source simulation_venv/bin/activatepip install -e .This installs the package in editable mode, allowing development without reinstallation.
A basic simulation with a single Node and one container can be executed using (simple.py):
python examples/simple.pyFor a multi-node environment with multiple Nodes and containers (multi_node.py):
python examples/multi_node.pyThe framework also supports running simulations entirely through a YAML configuration file. This allows you to define the entire simulation setup, including Nodes, Containers, Workloads, and Load Balancer configurations, without modifying the code.
- Create a YAML configuration file. See the Configuration Guide for details and examples.
- Run the simulation by specifying the configuration file:
python cli_starter.py --config path/to/config.ymlRefer to the Configuration Guide for a detailed breakdown of the configuration structure and an example YAML file.
With the First-Fit with Reservations Load Balancer, users can toggle workload reservations using the use_reservations parameter:
The scheduler considers workload start time and duration when assigning resources.
simulation = LbSimulation(use_reservations=True)The scheduler ignores workload timing and places them immediately if resources are available.
simulation = LbSimulation(use_reservations=False)- Represents a host with limited resources (CPU, RAM, Disk, Bandwidth).
- Hosts multiple containers and manages resource allocation.
- Monitors resource utilization over time.
- Supports fluctuation effects for realistic fluctuations.
- Runs inside a Node and consumes computing resources dynamically.
- Can receive workload requests, increasing resource usage temporarily.
- Tracks historical usage of CPU, RAM, Disk, and Bandwidth.
- Simulates incoming tasks that containers process.
- Each workload request has:
- CPU, RAM, Disk, Bandwidth requirements.
- Delay before execution starts.
- Duration for which it runs.
- fluctuation percentage to simulate fluctuating demand.
- Implements First-Fit with Reservations Scheduling for efficient workload placement.
- Uses the
use_reservationsparameter to toggle between:- Smart scheduling (default) β Considers workload start time & duration.
- Immediate scheduling β Places workloads as soon as resources are available.
- Prevents resource overload by rejecting excessive workloads.
- Uses SimPy to manage event-driven execution.
- Handles Node startup delays, container execution, and monitoring.
- Runs the simulation for a fixed duration and logs resource usage.
- Uses Matplotlib to plot resource usage over time.
- Tracks and displays:
- CPU, RAM, Disk, and Bandwidth consumption.
- Available resources after workload execution.
- Fluctuations over time.
After running a simulation, you will see terminal logs like:
[10] Node 'manager-1' Status - Containers: 3, CPU: 2.5/8.0 RAM: 2048/16384 Disk: 4096/20480 BW: 600/10000
[12] Container 'KeyCloak' updated workload: CPU 1.0/2.0 --> 1.5/2.0, RAM 1024/2048 --> 1536/2048
And generate graphs like:
π CPU, RAM, Disk, etc... usage over time
Want to contribute? Follow these steps:
- Fork the repo and clone it locally.
- Create a new branch (
git checkout -b feature-branch). - Make your changes and add docstrings.
- Push your changes (
git push origin feature-branch). - Create a pull request π.
Q: "ModuleNotFoundError: No module named 'cont_sys_sim'"
- Ensure you've activated the virtual environment (
source simulation_venv/bin/activate). - Reinstall the package:
pip install -e .
Q: "Simulation hangs indefinitely"
- Ensure you set an appropriate
simulation_timein your script.
This project is licensed under the MIT License.
TODO
π Author: Milan Balazs
π GitHub Repo: Container Simulation Framework

