Card 05/ 07

ExerciseDifficulty: Advanced2 min

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.

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