Fan-out sets the tail, so fetch from fewer stores
The more stores a request touches, the more often one of them is slow.
| Stores per request | Requests where at least one store is past its p99 |
|---|---|
| 1 | 1% |
| 3 | 2.97% |
| 10 | 9.6% |
The fetch goes to several stores at once: member batch features, the streaming store, an embedding store. In parallel, the stage takes as long as the slowest answer. So its tail is worse than any one store's.
Say each store is past its own p99 on 1% of requests, independently. Then
Here is the number of stores, and is the chance that all answer in time. The design method lesson works the general case from The Tail at Scale.
Fewer stores per request is the first fix. Then:
- Timeouts with fallbacks. Give each store a deadline inside the stage, say 20 ms. When it fires, use a fallback: the last value cached on the server with its age, the batch value in place of the streaming one, or a default.
- Defaults the model has seen. A fallback is a feature value, and if training never contained it, the model's output on it is a guess. Logged features handle this for free. With recomputed training data, blank the feature group in training at the rate you see online, and add an indicator that says the value was a fallback.
- Hedged requests. If a store hasn't answered by about its p95, send a second request to another replica. The Tail at Scale reports a benchmark where hedging after a 10 ms delay cut the 99.9th-percentile latency for fetching all 1,000 values from 1,800 ms to 74 ms. It sent just 2% more requests.
- One read per store. One multi-get per store per request, a single call that reads many keys. Never one call per candidate.
Netflix plans for failed fetches too. Its routing post lists fallback and client-side caching in case of failures among its goals. Its 2016 time machine tracked a confidence level for each service: the share of data fetches that succeeded, not counting fallbacks from timeouts or service failures.
In the editor, write p_any_slow(n) from the formula, and max_stores(target): how many stores a fetch can wait on before the slow share passes target.