Skip to content
System Designer

Work later · 3 minutes

Waiting instead of breaking

A queue lets a burst wait in line instead of crashing the thing behind it.

Open this lesson
A queue lets a burst wait in line instead of crashing the thing behind it.

A line at the bakery

If work arrives faster than it can be done, you can drop it or make it wait. A queue is the line. The sender says "got it" at once, and workers take items at their own pace. Waiting is better than breaking, as long as the line does not grow forever.

Backpressure

A queue buys time only when it can eventually drain. Admit more than the workers can serve, then bound the waiting work.

Try the idea

A burst of writes is more than the database can take. Put a queue and workers in front of it. Acceptance means the queue took the job, not that it finished. Completion lag shows the oldest waiting job; expiry risk compares its age with the job deadline. The model tracks traffic as rates rather than individual jobs.

Key numbers

Standard queue
≈ 100,000 messages a second. managed, approx.
Database writes
≈ 2,000 a second. one SQL primary, approx.
Backlog of 1 million at 2,000 a second
≈ 8 minutes to clear. With no new arrivals: 1,000,000 / 2,000 / 60 ≈ 8.3 minutes.
1,500 arrivals and 2,000 completed a second
≈ 33 minutes to clear 1 million. Net drain is service minus arrivals: 2,000 - 1,500 = 500 jobs a second. Time to clear = backlog / (service rate - arrival rate), so 1,000,000 / (2,000 - 1,500) / 60 ≈ 33.3 minutes. At equal rates the backlog stays; with more arrivals it grows.

Check your reasoning

Think through these questions before opening the lesson. In the game you can test the idea and compare your reasoning.

  • What does a queue buy you?
  • The queue grows all day and never shrinks. What now?
  • What is backpressure?

The key point

Queues turn spikes into waiting; backpressure stops the waiting from growing forever.

Practise this idea

Continue through the lesson tracks