Part 8 of 8 · 2 min read
Exercises
Easy
Easy 1: Priority ladder (20 minutes)
Make a five-level degradation ladder for a video streaming site.
Done when: a table of five levels with what is dropped.
Hint
Keep the thing that earns money or the reason the user came.
Easy 2: Token bucket by hand (20 minutes)
Size 5, refill 1 per second. Simulate 12 seconds with 3 requests every second. Mark which pass.
Done when: a table of seconds, tokens and results.
Hint
Add tokens before spending them, up to the size.
Easy 3: Which tool (20 minutes)
For each case, choose from rate limiting, shedding, levelling and auto-scaling: a bug in one client, a sale at noon, a slow rise over a week, all servers at 95 percent.
Done when: four choices with a reason each.
Hint
A slow rise is a case for capacity, not for protection.
Medium
Medium 1: Queue arithmetic (30 minutes)
A service handles 80 jobs a second. Arrivals are 300 per second for 20 seconds, then 40 per second. Find the peak queue and when it empties.
Done when: two numbers with the working shown.
Hint
The queue grows by arrivals minus 80.
Medium 2: Window edge (30 minutes)
A limit of 10 requests per minute with fixed windows. Show a sequence of requests that lets 20 through in 60 seconds. Then show how a sliding window counter handles it.
Done when: two tables of requests and results.
Hint
Put 10 at the end of one window and 10 at the start of the next.
Medium 3: Write a limiter (30 minutes)
Write a token bucket limiter in your favourite language and test it with a burst.
Done when: working code and a test that shows burst and refill.
Hint
Store the token count and the last refill time.
Hard
Hard 1: Distributed limiter (45 minutes)
Design a limiter for 20 instances and 1 million API keys. Choose the algorithm, the data store, the update method and what to do if the store is down.
Done when: a design with numbers for memory and requests per second.
Hint
Two numbers per key give 2 million numbers at most.
Hard 2: Overload plan (45 minutes)
For an online shop, write the plan for a 5 times traffic spike: what is limited, shed, queued and dropped, in what order, with the signals that trigger each step.
Done when: a runbook table of signals and actions.
Hint
Cheap early signals beat late expensive ones.
Hard 3: Deadline propagation (50 minutes)
A chain of four services has a 2 second end-to-end budget. Design how the deadline travels, what each service does when little time remains, and how to avoid retries that overrun the budget.
Done when: a design with a worked timeline.
Hint
A retry is allowed only if the remaining time covers it.