Tutorial 5 of 8 · System design · Data and work at scale · Intermediate
Queues and background work
Answer the user now, do the slow work later, and survive bursts, failures and repeats.
6 lessons, the last is a challenge · about 1 h · Diagrams, with Python and Java
Before you start
You finished "Scaling out: load balancers and stateless servers": you know what a server, a request and a response are, and that one server can handle only so many requests per second.
You finished "Stacks and queues": you know that a queue hands items out first in, first out.
1Move slow work behind a queue, and say how long the user waits with the work done inline and with it queued.
2Follow jobs through a queue tick by tick, and size the workers for a burst: say how long the queue gets, when it clears, and when more workers are the only fix.
3Plan for failure: say when a failed job is retried, why each wait is longer, and what the dead-letter queue is for.
4Make a job safe to run twice: say why a queue can deliver a job again, and write a handler that skips a job it has already done.