CAP Theorem Trade-offs
Problem Explain the CAP theorem, and where you would trade consistency for availability (or the reverse).
Be ready to discuss
- The three properties: Consistency (every read returns the most recent write), Availability (every request gets a non-error response), Partition tolerance (the system keeps operating despite network partitions).
- Why the real choice is CP versus AP: partitions are unavoidable in any real distributed system, so P is not optional — the decision only bites during a partition.
- CP examples and reasoning: a bank ledger, a leader-based config/coordination store like etcd or ZooKeeper — refuse the request rather than serve stale or conflicting data, because a wrong answer costs more than no answer.
- AP examples and reasoning: a shopping cart, a DNS-like lookup, a restaurant listing cache — stay responsive on slightly stale data and reconcile later, because unavailability costs more than staleness.
- Reconciliation mechanics for AP systems: last-write-wins, vector clocks, CRDTs, and the shopping-cart merge problem where a deleted item resurrects.
- Nuance: the choice is per-operation, not per-system — the same product can serve reads AP and take payments CP, which is what a strong answer surfaces.
- Beyond CAP: PACELC — even with no partition, you still trade latency against consistency, which is the trade-off systems make every ordinary day.
- What's evaluated: mapping the choice to a concrete system you have worked on rather than reciting the theorem.
asked …