Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# **FastSim – Event-Loop Aware Simulation for Backend Systems**
# **AsyncFlow – Event-Loop Aware Simulation for Backend Systems**

## **1. Overview**

Modern asynchronous Python stacks such as **FastAPI + Uvicorn** deliver impressive performance, yet capacity planning for production workloads often relies on guesswork, costly cloud-based load tests, or late-stage troubleshooting.

**FastSim** addresses this challenge by providing a **digital twin** of your service that can be run entirely offline. It models event-loop behaviour, resource constraints, and request lifecycles, enabling you to forecast performance under different workloads and architectural choices **before deployment**.
**AsyncFlow** addresses this challenge by providing a **digital twin** of your service that can be run entirely offline. It models event-loop behaviour, resource constraints, and request lifecycles, enabling you to forecast performance under different workloads and architectural choices **before deployment**.

FastSim allows you to answer questions such as:
AsyncFlow allows you to answer questions such as:

* *What happens to p95 latency if traffic doubles during a peak event?*
* *How many cores are required to maintain SLAs at scale?*
Expand Down Expand Up @@ -37,7 +37,7 @@ Until published, clone the repository and install in editable mode:
- Python 3.11+ (recommended 3.12)
- Poetry ≥ 1.6

FastSim uses [Poetry](https://python-poetry.org/) for dependency management.
AsyncFlow uses [Poetry](https://python-poetry.org/) for dependency management.
If you do not have Poetry installed, follow these steps.

### 3.1 Install Poetry (official method)
Expand All @@ -64,8 +64,8 @@ curl -sSL https://install.python-poetry.org | python3 -

```bash
# Clone the repository
git clone https://github.com/GioeleB00/Fastsim-Backend.git
cd Fastsim-Backend
git clone https://github.com/GioeleB00/AsyncFlow-Backend.git
cd AsyncFlow-Backend

# Configure Poetry to always create a local `.venv` inside the project
poetry config virtualenvs.in-project true
Expand Down Expand Up @@ -171,9 +171,9 @@ from pathlib import Path
import simpy
import matplotlib.pyplot as plt

from app.config.constants import LatencyKey
from app.runtime.simulation_runner import SimulationRunner
from app.metrics.analyzer import ResultsAnalyzer
from asyncflow.config.constants import LatencyKey
from asyncflow.runtime.simulation_runner import SimulationRunner
from asyncflow.metrics.analyzer import ResultsAnalyzer

def print_latency_stats(res: ResultsAnalyzer) -> None:
"""Print latency statistics returned by the analyzer."""
Expand Down Expand Up @@ -229,7 +229,7 @@ you will see the latency stats

## **5. Target Users and Use Cases**

| Audience | Challenge | FastSim Value |
| Audience | Challenge | AsyncFlow Value |
| ------------------------ | ------------------------------------------------- | -------------------------------------------------------------------------------- |
| Backend Engineers | Sizing services for variable workloads | Model endpoint workflows and resource bottlenecks before deployment |
| DevOps / SRE | Balancing cost and SLA | Simulate scaling scenarios to choose optimal capacity |
Expand All @@ -244,7 +244,7 @@ you will see the latency stats
The project follows a standard Python package layout, managed with Poetry.

```
Fastsim-Backend/
AsyncFlow-Backend/
├── examples/ # Examples payloads and datasets
├── scripts/ # Utility scripts (linting, startup)
├── docs/ # Project vision and technical documentation
Expand All @@ -265,7 +265,7 @@ Fastsim-Backend/

## **7. Development Workflow**

FastSim uses **Poetry** for dependency management and enforces quality via **Ruff** and **MyPy**.
AsyncFlow uses **Poetry** for dependency management and enforces quality via **Ruff** and **MyPy**.

| Task | Command | Description |
| ------------- | --------------------------------- | -------------------------------------- |
Expand Down
185 changes: 125 additions & 60 deletions docs/dev_workflow_guide.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/fastsim-docs/metrics_to_measure.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### **FastSim — Simulation Metrics**
### **AsyncFlow — Simulation Metrics**

Metrics are the lifeblood of any simulation, transforming a series of abstract events into concrete, actionable insights about system performance, resource utilization, and potential bottlenecks. FastSim provides a flexible and robust metrics collection system designed to give you a multi-faceted view of your system's behavior under load.
Metrics are the lifeblood of any simulation, transforming a series of abstract events into concrete, actionable insights about system performance, resource utilization, and potential bottlenecks. AsyncFlow provides a flexible and robust metrics collection system designed to give you a multi-faceted view of your system's behavior under load.

To achieve this, FastSim categorizes metrics into three distinct types:
To achieve this, AsyncFlow categorizes metrics into three distinct types:

1. **Sampled Metrics (`SampledMetricName`):** These metrics provide a **time-series view** of the system's state. They are captured at fixed, regular intervals (e.g., every 5 milliseconds). This methodology is ideal for understanding trends and measuring the continuous utilization of finite resources. Think of them as periodic snapshots of your system's health.

Expand Down
4 changes: 2 additions & 2 deletions docs/fastsim-docs/requests_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes the design of the **requests generator**, which models a

## Model Inputs and Output

Following the FastSim philosophy, we accept a small set of input parameters to drive a “what-if” analysis in a pre-production environment. These inputs let you explore reliability and cost implications under different traffic scenarios.
Following the AsyncFlow philosophy, we accept a small set of input parameters to drive a “what-if” analysis in a pre-production environment. These inputs let you explore reliability and cost implications under different traffic scenarios.

## **Inputs**

Expand Down Expand Up @@ -386,4 +386,4 @@ The sampling window length governs how often we re-sample $U$. It should reflect


**Key takeaway:** By structuring the generator as
$\Lambda = U\,\lambda_r/60$ with a two-stage Poisson→Exponential sampler, FastSim efficiently reproduces compound Poisson traffic dynamics without any complex CDF inversion.
$\Lambda = U\,\lambda_r/60$ with a two-stage Poisson→Exponential sampler, AsyncFlow efficiently reproduces compound Poisson traffic dynamics without any complex CDF inversion.
10 changes: 5 additions & 5 deletions docs/fastsim-docs/runtime_and_resources.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Of course. This is an excellent request. A deep dive into the "why" and the real-world analogies is what makes documentation truly valuable.

Here is the comprehensive, detailed documentation for the FastSim Runtime Layer, written in English, incorporating all your requests.
Here is the comprehensive, detailed documentation for the AsyncFlow Runtime Layer, written in English, incorporating all your requests.

-----

# **FastSim — The Runtime Layer Documentation**
# **AsyncFlow — The Runtime Layer Documentation**

*(Version July 2025 – Aligned with `app/runtime` and `app/resources`)*

Expand Down Expand Up @@ -80,7 +80,7 @@ Think of `RequestState` as a request context in a modern microservices architect
## **4 The Resource Layer — Modelling Contention ⚙️**

In real infrastructures every machine has a hard ceiling: only *N* CPU cores, only *M* MB of RAM.
FastSim mirrors that physical constraint through the **Resource layer**, which exposes pre-filled SimPy containers that actors must draw from. If a token is not available the coroutine simply blocks — giving you back-pressure “for free”.
AsyncFlow mirrors that physical constraint through the **Resource layer**, which exposes pre-filled SimPy containers that actors must draw from. If a token is not available the coroutine simply blocks — giving you back-pressure “for free”.

---

Expand Down Expand Up @@ -127,7 +127,7 @@ defensive checks beyond the simple dictionary lookup.
| RAM container tokens | **cgroup memory limit** or a pod’s allocatable memory; once exhausted new workloads must wait. |

Just like a Kubernetes scheduler won’t place a pod if a node lacks free CPU/RAM,
FastSim won’t let an actor proceed until it obtains the necessary tokens.
AsyncFlow won’t let an actor proceed until it obtains the necessary tokens.

## **5. The Actors: Bringing the System to Life**

Expand Down Expand Up @@ -448,4 +448,4 @@ def _forwarder(self) -> Generator[simpy.Event, None, None]:

With these mechanics the `LoadBalancerRuntime` faithfully emulates behaviour of
production LBs (NGINX, HAProxy, AWS ALB) while remaining lightweight and
fully deterministic inside the FastSim event loop.
fully deterministic inside the AsyncFlow event loop.
Loading