Part 8 of 8 · 3 min read
Exercises
Easy
Easy 1: Name the parts (20 minutes)
A user uploads a profile photo. A web server stores it, and a worker makes three smaller versions. Draw the flow and label the producer, the consumer, the queue and the message.
Done when: a diagram with four labels and one sentence on what the user waits for.
Hint
The user waits only until the original file is stored and the message is accepted.
Easy 2: Drain time (20 minutes)
A queue holds 12,000 messages. Consumers handle 150 per second. New messages arrive at 50 per second. How long until the queue is empty?
Done when: the net rate, the time in seconds and in minutes.
Hint
The queue shrinks at the consumer rate minus the arrival rate.
Easy 3: Share or broadcast (20 minutes)
For each case say load balancing or fan-out: resizing images; telling three services that a user signed up; sending 1 million emails with 20 workers; updating a search index and a cache from one product change.
Done when: four answers with a reason each.
Hint
Ask whether every receiver needs every message.
Medium
Medium 1: Size the spike (30 minutes)
Normal load is 300 messages per second. A promotion gives 1,500 per second for 2 minutes. Consumers process 500 per second. Find the backlog at the end of the spike, the time to drain and the longest wait of any message. Then find how many consumers (each 100 per second) keep the longest wait under 60 seconds.
Done when: four numbers and the consumer count with working.
Hint
Backlog is arrivals minus processing during the spike. Waiting time is backlog divided by rate.
Medium 2: Trace a crash (30 minutes)
Consumers C1 and C2 read from one queue with a 20-second visibility timeout. Messages m1 to m5 arrive. C2 takes m3 and crashes at second 4. C1 handles m4 at second 5 and m5 at second 9. Write the order in which C1 processes messages, and the time m3 returns.
Done when: a timeline, the processing order and a sentence on what ordering rule was broken.
Hint
m3 reappears when the timeout ends, 20 seconds after it was taken.
Medium 3: Retry policy (30 minutes)
A payment email queue gets a bad message every 1,000 messages. Choose a retry limit and a dead letter queue policy. State the alert you would add and who replays the messages.
Done when: a written policy with a number, an alert rule and a replay step.
Hint
Three or five attempts is common. The key is that someone is told.
Hard
Hard 1: Notification system (45 minutes)
Design a queue layout for notifications through SMS, email and push, with three third-party providers. Say how many queues, which scale on their own, what happens when the SMS provider is down for an hour and how the backlog is cleared after.
Done when: a design with a diagram, a failure walk-through and drain time with made-up numbers.
Hint
One queue per provider keeps an outage inside one queue.
Hard 2: Queue or call (45 minutes)
For a booking site, list eight actions (search, pay, send confirmation, update recommendations, resize photos, check seat availability, write an audit entry, send a review reminder). Mark each as direct or queued with a one-line reason, and say what the user sees for the queued ones.
Done when: a table of eight rows with user-visible state for each queued item.
Hint
If the user needs the result on the same screen, it is a direct call.
Hard 3: Slow consumer incident (50 minutes)
A queue's depth rises steadily over six hours although consumers look healthy. Give five possible causes, how to tell each apart with metrics, and what to do first. Include a case where adding consumers makes it worse.
Done when: a table of five causes with a metric and a fix each.
Hint
A shared database or lock can be the real limit, and more consumers add pressure on it.