As per the definition of CAP theorem, there can be only 2 conditions satisfied by any distributed system. Traditionally Cassandra is an AP system. If we use a consistency level like LOCAL_QUORUM, it ensures strong consistency also.
Assuming we always have to maintain Partition Tolerance, if we use LOCAL_QUORUM and Replication factor, we can ensure strong Consistency and Availability. Does it go against CAP theorem or am I missing anything?
PS: For simplicity consider we have only one Datacenter.
No, unfortunately you can't cheat the CAP theorem with Cassandra. Cassandra allows you to tune consistency for your needs, however.
LOCAL_QUORUM
means that for reads and writes the client waits for a majority (for example two of three) of nodes to acknowledge the operation before returning. If the client uses LOCAL_QUORUM
for both reads and writes it prioritises consistency over availability. It doesn't mean it needs all nodes to be up at all times, but a majority must be. In this scenario, if the cluster is partitioned, clients that see the minority partition cannot continue.
The client can also prioritise consistency by writing at consistency level ALL
and reading at ONE
, or vice versa – but in this scenario all nodes have to be up.
If the client uses combinations of consistency levels where reads and writes are not guaranteed to overlap, such as ONE
for both reads and writes, it priorities availability. With a partitioned cluster, the client can continue reading and writing as long as it can communicate with any node.
Clients can also mix consistency levels that don't guarantee consistency, but are less susceptible to consistency errors, such as using LOCAL_QUORUM
for writes and ONE
for reads. This combination can be useful when you want to make sure that writes are not lost, but it's not important reads are immediately up to date.