As asked
Explain the CAP theorem. Give me a concrete example of a system that prioritizes CP and one that prioritizes AP, and tell me how each behaves during a network partition.
Sample answer outline
CAP states that a distributed system can provide at most two of: Consistency (every read returns the latest write), Availability (every request gets a response), and Partition Tolerance (the system continues operating during network splits). During a partition, a CP system (Zookeeper, HBase) rejects requests on the minority partition to preserve consistency. An AP system (Cassandra, DynamoDB) continues serving requests but may return stale data. A strong answer notes that partition tolerance is non-negotiable in real networks, so the real choice is between consistency and availability under partition, and mentions PACELC as a more nuanced model.
Expect these follow-ups
- How does eventual consistency differ from strong consistency in terms of developer guarantees?
- Where does Postgres sit in the CAP model and does that change in a read-replica setup?