Card 05/ 07
Practice: Diagnosing Ten Failures at Scale
Ten incident reports, each a symptom: name the failure and its fix.
Recognising a failure from its symptom is practised here on ten incident reports, none of which a test suite would catch. For each, name the failure and one fix before opening the answers.
The reports.
- The home page cache entry expires at 09:00 and the database is overwhelmed for a minute.
- After a ten-second outage, every client reconnects in the same instant, and the service falls over again.
- One shard of the cache sits at 100% while the other nine idle; one celebrity's profile is on it.
- An orders page that took 20 ms with ten orders takes 20 seconds for a customer with ten thousand.
- The search service slows down; clients retry, traffic triples, and search stops entirely.
- An application server runs fine for months, then crashes with out-of-memory, again and again.
- One slow report query runs at lunchtime, and every other request hangs waiting for a database connection.
- A user saves their new address, refreshes, and sees the old one.
- A network glitch, and one customer is charged twice for one order.
- A queue grows all day and the broker runs out of memory at 18:00.
Check your diagnoses
- Cache stampede. One request rebuilds the entry while others get the old copy.
- Thundering herd. Random jitter on reconnect delays.
- Hot key, one key taking a large share of traffic. Copy it to several nodes, or split it with a suffix.
- N+1 queries. One query with a join, or a batch.
- Retry storm. Exponential backoff, and a circuit breaker, which stops calls to a failing service for a while.
- Unbounded cache. A size limit with LRU eviction, and an expiry on every entry.
- Connection pool exhaustion. Query timeouts, and long queries moved off the main pool.
- Replica lag, a read from a copy that has not caught up. Read from the primary briefly after a user's own write.
- Missing idempotency. An idempotency key on each payment, so a repeat is ignored.
- No backpressure. Cap the queue, slow the producer.
- System Design
- Fault Tolerance
- Performance
← → move through sections and cards