Chapter 15: Performance and cost

Tail latency

Also called p99 latency, Hedged request

The slowest few requests, far along the end of the distribution. One in a hundred sounds rare until a single page makes dozens of requests and waits for them all, at which point a lot of people meet that one.

Chances stack up: with ten requests per page, about one page view in ten hits a p99. An agent run does the same thing, because a session making 40 calls has a one in three chance of meeting a 1-in-100 slow one. So a slow call that looks rare per request is routine per session, and a retry or a timeout has to expect it.

Say it to your agent

“This page makes 12 API calls and waits for all of them. Log the duration of each, tell me which one sets the page's p99, and give every call a timeout. Don't retry a call that writes data unless it is idempotent.”

The workshop

Name a word, or describe what you mean in everyday language.