System Design Lab / Simulation

Model a queue under pressure

Compare bursty arrivals, processing capacity and dropped jobs in a bounded, deterministic queue.

You will learn to

  • Distinguish throughput from queue size
  • Locate overload in a trace
  • Explain a backpressure trade-off

Before you start

Basic programming and the introductory activities

Define a tick

One tick is an abstract time unit. At its beginning, arrivals join the queue until the queue reaches its configured capacity. Excess arrivals are dropped. Each worker then completes one waiting job. This ordering matters: a simultaneous arrival cannot use a slot that will become free later in the same tick.

A bigger buffer is not faster

Increasing the queue capacity can absorb a short burst, but it does not change how many jobs workers finish per tick. When the long-run arrival rate exceeds processing capacity, a finite queue eventually fills. More capacity postpones the drop; it does not repair the imbalance.

Interpret the trace

Start with arrivals 2,2,8,8,2,0,0, two workers and capacity ten. The queue absorbs the first burst; the second burst loses four jobs under this model. The zero-arrival ticks help drain the backlog. Compare capacity six with ten while keeping workers constant, then change workers instead.

Design beyond the model

A real service might reject early, retry with jitter, scale workers or partition work. Retries can amplify traffic if every caller retries immediately. This simulator has no network, variable processing times, priorities or durable storage. Use it to explain a trade-off; do not present its ticks as a production benchmark.

Try it yourself

Enable JavaScript for this interactive activity. You can read all lesson explanations above without it.

Continue exploring