Cassandra低一致性级别优势显著,为何仍需QUORUM、ALL等高一致性级别?
ONE in Cassandra? Great question! It makes total sense to wonder why we’d bother with higher consistency levels like QUORUM or ALL when ONE delivers such fast read/write speeds and high availability. The answer boils down to a core tradeoff in distributed systems: speed/availability vs. data correctness/consistency. Let’s break down the key scenarios where higher CLs are non-negotiable:
Critical operations demand guaranteed data correctness
Imagine a banking transfer: when you send money from your account, you need to be 100% sure the next read of your balance reflects the deduction. If you useCL=ONE, there’s a chance you’ll read a stale copy from a node that hasn’t synced the write yet. This could lead users to mistakenly initiate a second transfer, causing costly financial errors.QUORUMsolves this by requiring a majority of nodes to confirm the write (or return the latest data for a read), ensuring you’re working with the most up-to-date state.Stale reads can break business logic
For systems like inventory management or ticket booking, stale data creates real-world problems. If a user checks inventory withCL=ONE, they might see available tickets that were actually just purchased (but the sync to their queried node hasn’t completed). This results in overbooking and unhappy customers. Higher CLs likeQUORUMdrastically reduce the risk of stale reads by prioritizing consensus across most nodes over raw speed.Compliance and regulatory rules may mandate stronger consistency
Industries like finance, healthcare, and government often have strict regulations requiring data to be reliably persisted and accessible in its correct state. UsingCL=ONEdoesn’t guarantee your write was saved to more than one node—if that single node fails, you could lose data entirely.QUORUMensures writes are stored on a majority of nodes, meeting durability requirements. In rare cases where full consensus is needed (e.g., sensitive patient records),ALLmight be required (though it’s rarely used due to its vulnerability to node failures).Preventing split-brain data conflicts
During network partitions (when part of the cluster is cut off from the rest),CL=ONEallows both partitions to accept writes independently. When the cluster reconnects, you’ll end up with conflicting versions of the same data that need messy resolution.QUORUMavoids this because only one partition can satisfy the "majority node" requirement—so writes are only allowed in the partition that still has a majority of the cluster, preventing conflicting data from being created in the first place.
At the end of the day, CL=ONE is perfect for scenarios where occasional stale data is acceptable (like a social media feed, non-real-time analytics, or product recommendations). But for any use case where data accuracy is critical, you’ll need to opt for higher consistency levels to avoid costly mistakes.
内容的提问来源于stack exchange,提问作者Ankita Hrishikesh Upadhyay

