Key Terms
| Term | In one line |
|---|---|
| CAP | Under a partition you choose Consistency or Availability — P is not optional |
| PACELC | The version to actually use: under P choose A or C; Else (no partition) choose Latency or Consistency |
| Linearizable | Every read returns the most recent committed write |
| Bounded staleness | Reads lag by at most K versions or T time |
| Session consistency | A client always reads its own writes |
| Consistent prefix | Replicas never see writes out of order — stale but never scrambled |
| Raft | Leader election + replicated log; the consensus algorithm to explain |
| Circuit breaker | Closed → open → half-open; stop calling a failing dependency |
| Bulkhead | Isolate resource pools so one failure can’t drain the whole service |
| Jitter | Randomness added to backoff so retries don’t synchronize into a thundering herd |
| RTO / RPO | How long until you’re back / how much data you can lose |
Numbers That Matter
| Figure | Value | Where it bites |
|---|---|---|
| 99% | 3.65 days/yr | — |
| 99.9% | 8.7 hours/yr | The default enterprise target |
| 99.95% | 4.4 hours/yr | — |
| 99.99% | 52.6 minutes/yr | Needs multi-AZ active-active |
| 99.999% | 5.3 minutes/yr | Each nine ≈ 10× the effort — know if you actually need it |
| DR ladder | Backup/restore → pilot light → warm standby → active-active | RTO/RPO improves and cost rises at each step |
Decision Rules
- Use PACELC, not CAP. CAP only describes behaviour during a partition, which is rare. PACELC also covers the normal case, where the real trade-off is latency versus consistency — and that’s the one you live with every day.
- Classify by PC/PA and EL/EC: Cosmos strong = PC/EC; Cosmos eventual = PA/EL; Cassandra and DynamoDB eventual = PA/EL; MongoDB primary reads = PC/EC.
- Pick the weakest consistency model that satisfies the requirement. Session consistency solves most “user sees their own update” complaints at a fraction of the cost of linearizability.
- Retry only idempotent operations, always with exponential backoff and jitter, always with a cap. Retries without jitter convert one blip into a synchronized stampede.
- Circuit breaker plus timeout plus fallback, not one of them. A circuit breaker with no timeout still lets calls hang; a timeout with no breaker keeps hammering a dead dependency.
- Sharding strategy: hash for even distribution but painful rebalancing; range for scan locality but hotspots; directory for flexibility with a lookup dependency; tenant-based for isolation; consistent hashing with virtual nodes when nodes join and leave.
- Choose a DR tier from RTO/RPO, then price it. Pilot light when hours of RTO are acceptable; warm standby for minutes; active-active for near-zero — and be explicit that active-active means solving conflict resolution.
- Lambda vs Kappa: Lambda runs batch and speed layers with duplicated logic; Kappa is stream-only and simpler. Default to Kappa unless you genuinely need reprocessing semantics batch gives you.
Say This Out Loud
“I’d rather talk in PACELC than CAP. CAP only tells you what happens during a partition, and partitions are rare — the trade-off you actually live with every day is the else branch: latency versus consistency in normal operation. Saying a database is ‘AP’ tells me almost nothing; saying it’s PA/EL tells me it stays available under partition and it’ll give me a fast stale read the rest of the time.”
“Before I pick a consistency model I ask what the user actually notices. Most of the time the complaint is ‘I updated my profile and it still shows the old one,’ and that’s session consistency — read-your-own-writes — not linearizability. Reaching for strong consistency when session consistency would do is one of the most expensive reflexes in distributed design.”
“Every retry I write is idempotent, capped, exponentially backed off, and jittered. The jitter is the part people skip, and it’s the part that matters — without it, every client that failed at the same moment retries at the same moment, and you’ve turned a two-second blip into a synchronized stampede that keeps the service down.”
“Each additional nine costs roughly an order of magnitude more in engineering and operational effort. Three nines is about eight and a half hours a year and a well-run multi-AZ setup. Four nines is fifty-two minutes and needs active-active with automated failover. Five nines is five minutes a year, and I’d want to see the contractual reason before designing for it.”