AlgoViz

Timeouts

easy 30 min

A timeout is the longest time you are willing to wait for something.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

Every wait has an end, and you choose it.

The bus stop: buses come within 8 minutes, the walk takes 20, the lesson is at 3:30. So wait until 3:10, then walk.

Cheat sheet

Limits
pool, connect, write, read, total
Value
p99.9 plus room (0.1% wrong cuts)
Threads held
rate x timeout
Chain
outer >= attempts x inner + pauses + own
Deadline
pass the remaining time
Not enough time
refuse, never extend
Timed-out write
unknown: same key, or ask
Adaptive
average + 4 x variation, with a ceiling
Hedge
second copy after p95: about 5% more
HTTP
408 slow client, 504 slow server behind

Spot it when you see

  • Any arrow to another machine.
  • Thread pool exhausted.
  • A spinner that never ends.
  • A chain of services.

Tricks that stick

  • TIME OUT: T, TCP connect limit first. I, individual limits per operation. M, monitor and log. E, err on neither side: p99.9 plus room. O, order: outer longer than inner. U, use deadline propagation. T, test with delays.
  • Silence means unknown.
  • A child can only be given what the parent has left.

Do not forget

  • Trusting library defaults.
  • Read limit taken for a total limit.
  • Inner limit longer than outer.
  • Inventing time for a late request.
  • Leaving the task running after the limit.