.NET Architecture & System Design Interview Question #70

What is the CAP theorem?

Database Scaling, Partitioning, NoSQL & Data Consistency Mid-Level Intermediate

Quick Interview Answer

The CAP theorem states that when a distributed data system experiences a network partition, it cannot simultaneously guarantee both strong consistency and availability for every operation.

Detailed Explanation

The CAP theorem states that when a distributed data system experiences a network partition, it cannot simultaneously guarantee both strong consistency and availability for every operation.

Partition tolerance is unavoidable when independent nodes communicate over unreliable networks, so during a partition a design must decide how particular operations behave. CAP does not mean a database is permanently only 'CP' or 'AP' in every situation.

Code Example

During network partition:

Consistency
     /    /     /    Partition ---- Availability

Cannot guarantee all three
simultaneously during the partition.