What is the CAP theorem and how does Cassandra fit?
Answer
The CAP theorem states that a distributed system can guarantee at most two of three properties: Consistency (all nodes see the same data at the same time), Availability (every request gets a response), Partition tolerance (system continues despite network partitions). Since network partitions are unavoidable in distributed systems, the real choice is between CP (favor consistency when a partition occurs) and AP (favor availability). Cassandra is AP by default: it prioritizes availability and partition tolerance. When a partition occurs, Cassandra continues accepting reads and writes — but may serve stale data. However, Cassandra offers tunable consistency — you can choose strong consistency at the cost of availability: consistency QUORUM reads/writes require a majority of replica nodes, making Cassandra more CP-like. consistency ALL requires all replicas. consistency ONE is maximum availability (AP). Most production deployments use QUORUM for a balance of consistency and availability.