StackMonkey

Numbers validated against queueing theory, not animated request flow.

The simulator's test suite runs the engine against eight textbook queueing results and fails if the simulated numbers drift too far from the formulas. The checks hold in steady state, with timeouts and retries switched off; timeouts, retries, caches under failure and load shedding have no closed form, so they are tested for behaviour, not against a formula.

8 checks
Queueing results compared with the simulation
±5%
Mean latency tolerance in most checks (7 to 12% where noted)
±0.6 pts
Blocking probability tolerance for finite queues

8 Queueing Results the Simulator Is Tested Against

Each check runs a seeded simulation at fixed parameters and compares it with the formula. The tests live in the simulator's own repository, which is not public yet, and run with npm test there. Theory applies strictly under steady-state conditions (timeoutMs = 0 and maxRetries = 0).

Check 1 · Single server Latency within 5%

M/M/1 mean latency

One worker with Poisson arrivals at 50 requests a second and exponential 10 ms service, so it is 50% busy. The simulated mean latency must land within 5% of the formula, and utilization within 2 points.

Closed form:
W = 1 / (μ − λ) = 20 ms
λ = 50/s · 1 worker · 10 ms Seeded run
Check 2 · Worker pool with a finite queue Latency within 5%, blocking within 0.6 pts

M/M/c/K latency and blocking

Four workers at 40 ms with a 10-slot queue and 90 requests a second, so the pool is about 90% busy and some requests are turned away. Mean latency must be within 5%, utilization within 2 points and the drop rate within 0.6 points of the closed form.

Closed form:
P_block = π(c + K) of the birth-death chain
λ = 90/s · c = 4 · K = 10 Seeded run
Check 3 · Full graph engine Blocking within 0.6 pts

The same queue built on the canvas

The M/M/4/10 queue above, built from a client box and a service box in the graph engine, then again behind a load balancer that should change nothing. Both must match the closed form for latency, utilization and drops.

Closed form:
Same M/M/c/K result, through the full engine
client → service, and client → LB → service Seeded run
Check 4 · Request conservation Exact count

Every request is accounted for

After two minutes of overload, every request that arrived must be completed, dropped, shed, timed out or still in the system, with nothing lost or counted twice. Little's Law (L = λW) is checked separately in the theory model, to six decimal places.

Invariant:
arrivals = completed + dropped + shed + in flight
λ = 200/s · c = 4 · 120 s Seeded run
Check 5 · Long-tailed service Latency within 12% at cv 3

M/G/1 Pollaczek-Khinchine

Service times with a coefficient of variation of 3, a long tail like slow database queries. The simulated mean must be within 12% of the Pollaczek-Khinchine formula and more than twice the exponential case.

P-K mean wait:
W_q = ρ · E[S] · (1 + Cs²) / (2(1 − ρ))
λ = 50/s · 10 ms · cv = 3 Seeded run
Check 6 · Constant service time Latency within 5%

M/D/1 deterministic service

Every request takes exactly 10 ms. The formula predicts half the queueing wait of the exponential case, and the simulated mean latency must be within 5% of it.

Reduction:
W_q(M/D/1) = ½ · W_q(M/M/1)
λ = 50/s · 10 ms · cv = 0 Seeded run
Check 7 · Splitting traffic Latency within 7% per server

Random balancing and cache thinning

A random load balancer splits 160 requests a second across two M/M/4/10 servers, and each must match theory at 80 a second. A cache with an 80% hit ratio must pass 20 of 100 requests a second to the database. Round robin is only checked for an even split: it makes arrivals more regular than Poisson, so the formula does not apply to it.

Thinning:
A Poisson stream λ split with probability p is Poisson pλ
λ = 160/s split 50/50 · cache hit 0.8 Seeded run
Check 8 · Fixed crowd of users Latency within 5%, throughput within 2%

Closed-loop finite source

A fixed crowd of users who each wait 1 s between requests: 50 users, then 200 that saturate four workers at 40 ms. Throughput must be within 2% and mean latency within 5% of the finite-source model.

Interactive response time law:
X = N / (R + Z)
N = 50 and 200 · Z = 1 s · c = 4 Seeded run

Where Every Number Comes From

A simulator is only as trustworthy as its inputs. StackMonkey explicitly tags the provenance of every component and parameter so you can audit the chain of evidence.

Benchmarked

Hardware Loopback Tests

Base framework and storage engine costs timed on dedicated 2 vCPU loopback hardware. Covers Rust, Go, Java 21, Node 22, Python 3.13; Postgres 16, MariaDB, Redis 7, and RabbitMQ.

Rule-of-Thumb Band: ±25%
Published

Cloud Vendor Limits

Derived directly from published SLA and architecture limits: DynamoDB partition token buckets, Kafka partition consumer group concurrency, and S3 503 SlowDown capacity ceilings.

Rule-of-Thumb Band: ±40%
Modelled

Algorithmic Queues

Approximations for complex multi-node distributed primitives where loopback timing is impractical: multi-region network latency, Cassandra replica rings, and cross-shard scatter-gather.

Rule-of-Thumb Band: ±50%
Assumed

User-Defined Logic

Your proprietary business logic, custom service runtimes, and external third-party webhook latencies. These inputs are provisional placeholders until calibrated with production telemetry.

Calibrate via Your Metrics

Why Math Alone Fails in Production

Closed-form queueing equations only apply in steady state with zero timeouts (timeoutMs = 0) and zero retries (maxRetries = 0). The instant clients begin timing out after 150ms and retrying three times, the steady-state assumption collapses:

Retry Storm Amplification
Duplicate requests artificially 4x real ingress load into already saturated workers, breaking Markovian Poisson arrival distributions.
Downstream Worker Starvation
Upstream Go/Node workers block waiting on slow database connections, cascading thread pool depletion upstream all the way to the API Gateway.
Catastrophic OOM Drops
Accumulating queues consume process RSS memory until the Linux OOM killer terminates the process and takes down the instance group.

Textbook equations establish the baseline ceiling; StackMonkey’s discrete event engine simulates the nonlinear cascade that closed-form math cannot calculate.

8 Honest Technical Bounds (What We Do Not Model)

We believe in total transparency. StackMonkey is designed to evaluate architectural queue contention, backpressure, and capacity limits, not to make inflated claims.

01 · Discrete Events Only
Validates queue dynamics and resource contention, not compiled C++, Rust, or Java bytecode execution.
02 · Sequential Call Paths
Calls on outgoing edges execute sequentially per worker branch; parallel thread fan-out is modeled via separate worker tiers.
03 · Network Latency Model
Network delay is modeled on the answer path with jitter (0.6x to 1.4x); low-level BGP routing and TCP congestion windows are not modeled.
04 · Blocking by Default
A node holds its worker for its own work and all downstream calls until response or timeout, accurately simulating cascading stalls.
05 · 1-Second Aggregations
Telemetry metrics represent 1-second rolling averages; microsecond sub-tick microbursts are aggregated into interval stats.
06 · Standardized Hardware
Runtime benchmark costs are measured on standardized 2 vCPU loopback VMs, not variable multi-tenant cloud instances.
07 · Process Memory Bounds
Process memory tracks base RSS + per-call buffers; JVM generational garbage collection pauses and compaction stalls are omitted.
08 · Input Calibration
Default latency and cost parameters are provisional estimates until calibrated against your production Datadog or Prometheus logs.

Simulate Your Design Against Textbook Theory

Drag boxes, configure queue depths, inject failure scenarios, and verify where your architecture breaks before shipping to production.

Queue Theory Applied to Production Architectures

See how Little’s Law, finite buffer drops, and service time variance show up in the system design templates.

View all 10 templates
M/M/1/K Dropped Calls

Rate Limiter System Design

Finite capacity token buckets that reject traffic with HTTP 429 once buffers fill, preventing thread starvation.

Little’s Law (L = λW)

URL Shortener System Design

Calculates how 50k QPS across 25ms database latency demands 1,250 concurrent connections, overflowing standard connection pools.

Closed Queue Feedback

Chat System Design

500k persistent WebSockets where client reconnections create a closed population loop that triggers thundering herds.

Erlang-B Multi-Server Loss

Video Streaming System Design

Models multi-CDN edge POP caching without queue buffers, determining loss probability when origin bandwidth saturates.