Part 8 of 8 · 2 min read
Exercises
Easy
Easy 1: Backoff table (20 minutes)
Write the delays for 8 attempts with an initial backoff of 1 second and caps of 10 and 60 seconds.
Done when: two rows of 8 numbers.
Hint
The cap stops growth. Stop doubling when you reach it.
Easy 2: Retry or not (20 minutes)
For each error, say retry or fail fast with a reason: connection reset, 403 forbidden, 503 service busy, timeout on a payment.
Done when: four answers with reasons.
Hint
Ask whether trying again could ever succeed.
Easy 3: Amplification count (20 minutes)
A chain has 5 services, each allowing 3 attempts. Compute the worst case calls to the last one, and with retry at one level only.
Done when: two numbers.
Hint
Multiply the attempts of every level except the last.
Medium
Medium 1: Pick a timeout (30 minutes)
Given response times (median 80 ms, p99 250 ms, p99.9 900 ms, p99.99 5 s), choose a timeout for 1 percent, 0.1 percent and 0.01 percent false timeouts, and say what each costs.
Done when: three timeouts with the cost of each.
Hint
Read the percentile column that matches the rate.
Medium 2: Jitter simulation (30 minutes)
Write a short script that simulates 1,000 clients retrying with and without jitter for 10 seconds. Count calls per second in each case.
Done when: a script and two tables of counts.
Hint
Without jitter, all clients use the same times.
Medium 3: Total time budget (30 minutes)
A user request has a 5 second limit. It makes one call with 3 attempts, a 700 ms timeout and delays of 0.5 s and 1 s. Compute the worst total and say whether it fits.
Done when: a calculation and a decision.
Hint
Add the three timeouts and the two delays.
Hard
Hard 1: Design the client wrapper (45 minutes)
Write the interface of a remote-call wrapper: timeout, retries, backoff, jitter, idempotency key and metrics. State the defaults and why.
Done when: an interface with defaults and one paragraph of reasoning.
Hint
Defaults should be safe if no one reads the docs.
Hard 2: Payment retry plan (45 minutes)
A payment call times out half the time during an incident. Design the retry, the idempotency key, what the user sees, and how you confirm what happened.
Done when: a sequence description and a table of outcomes.
Hint
The key lets the provider spot a repeat.
Hard 3: Pick the retry level (50 minutes)
A request passes through a browser, an API gateway, an order service, a stock service and a database. Choose the one level to retry at, and justify with amplification numbers.
Done when: a choice with a calculation for two alternatives.
Hint
Prefer the level that knows if the call is safe to repeat.