~learn.
0:00 / 1:25
W02 · Failure-first design

A 5-second request that runs for 8, for a user who already left

transcript

The user gave up after 5 seconds. Closed the tab. Your servers could keep working on it until second 8.

The user calls the gateway. They'll wait 5 seconds. The gateway gives payment 5 seconds. Seems fair. Payment gives the bank 5 seconds too. Every hop starts its own clock.

The user sends the request. The clock starts. Getting to payment takes 3 seconds. Payment still starts a fresh 5 for the bank. At 5 seconds, the user gives up. The bank call can run to 8. Work done for someone who left.

The fix: pass one deadline down the whole chain. This request must finish by 10 o'clock and 5 seconds. Payment gets it at 10 o'clock and 2 seconds. It has 3 seconds left. So it gives the bank 2 point 5, keeping a 500 millisecond buffer. The answer beats the deadline.

And if a request arrives after its deadline? Don't even start. Return deadline exceeded. gRPC has this built in. It sends the time remaining, so clock skew doesn't bite.

Per-hop timeouts add up. A deadline only counts down. Propagate the deadline, and no hop outlives the user.

Full breakdown in the lecture.