Timeouts 00:00:01 Give the whole restaurant order one timer A cafe's menu page calls a reviews service. Connecting, sending the request and reading its response are separate phases. A timer per phase can let the total exceed the visitor's patience. 0.5 seconds to open the connection. Far below a connect limit of 3 seconds. 0.1 seconds more. The clock says 0.6. The server needs 2.0 seconds and the answer 0.1. In total 3.0 seconds, inside the limit of 5. If the server hangs after the earlier phases, the five-second total deadline fires five seconds after the call began. A five-second read limit alone can end later. Track an end-to-end deadline and any phase limits the client actually enforces. Verify whether connection establishment, name resolution and body reads are covered by your library's settings. 00:00:57 Five waiting tables can close the entire cafe A dependency pauses, yet the cafe keeps accepting four calls per second. Each stuck call occupies some finite resource. Soon a request asking only for opening hours cannot obtain a worker. 4 requests a second, a quarter of a second each: one thread is busy on average. Each thread works a moment, then waits. Three are waiting already. It only wanted the opening hours. There is no thread for it. 4 a second with a limit of 0.5 seconds: 2 threads wait, 3 are free. The page comes without reviews. Bound the number of waiting calls as well as their duration. Returning a page without optional reviews is useful if the page clearly preserves its essential information. 00:01:44 Choose the timer from both sides of the counter A timer that fires too early discards good answers. A timer that fires too late holds resources during failures. Start from the user's deadline, measured latency distribution and the tolerated false-timeout rate. A limit of 100 milliseconds throws away every fifth good answer. 10 in 1,000 are cut. At a small slowdown it becomes many, and the retries add load. 2 seconds cut almost nothing, but a hang holds 20 times as many threads as a limit of 100 ms. 350 ms plus a little room: 400 ms. Then check it against the pool and the user's deadline. Measure cold connections, peak load and slow successful responses. A percentile measured in a quiet process can produce a burst of retries precisely when the service begins slowing down. 00:02:36 Pass the remaining minutes, not a fresh timer A gateway spends part of the customer's time before calling orders. Orders spends more before calling payments. Resetting a full timeout at every hop lets descendants outlive the request they serve. 30, 20, 10, 5 seconds. Each outer limit is longer than the inner one, and that is right. But nobody knows how much was already used. The user gets an answer within 2 seconds. The gateway passes on 1.9. Payments uses 0.2 and keeps 0.1. The bank has 0.9 seconds and needs 0.4. Good. Now orders took 1.7 seconds. 0.1 is left, payments needs 0.3 and refuses. The bank is never asked. Propagate the remaining budget and leave time to return an answer. Decline work that cannot usefully finish, and propagate cancellation where the server and downstream library support it. 00:03:34 The card is charged after the caller stops waiting The caller times out and frees its table. The remote service can still complete the payment, because waiting and execution are different activities. A missing answer leaves the outcome unknown. The shop asks for 20 dollars with a limit of 1 second and the key order-7. After 1 second there is no answer. The thread is free again. A little later the card is charged. The answer reaches nobody. A worker repeats order-7. The company finds the key and returns the first result. One charge. Reuse the original payment identity, query the provider or apply its idempotent retry contract. A deadline tells us when to stop waiting. Only durable business state tells us whether money moved.