I am researching the CAP Theorem (Consistency, Availability, Partition Tolerance) in the context of NoSQL databases. For a global application where partition tolerance is a must, how do I decide between prioritizing Availability (AP) or Consistency (CP)? Are there any "NewSQL" solutions that actually bridge this gap effectively, or is the trade-off still a fundamental law we must follow?
3 answers
The CAP Theorem is a hard limit for distributed systems. In a network partition, you must choose between Consistency and Availability. For a financial app, you almost always want a CP system like MongoDB or HBase to ensure every user sees the same balance. If you chose an AP system like Cassandra, a user might see a stale balance, which is a nightmare for banking. "NewSQL" systems like Google Spanner or CockroachDB attempt to provide "the best of both worlds" using atomic clocks and Paxos/Raft consensus algorithms, but even they have slight latency trade-offs during network failures.
What level of latency is acceptable for your users if the system has to wait for a global consensus to ensure consistency?
For global apps, Partition Tolerance is a given because networks fail. Most developers pick AP for social media and CP for anything involving money.
Exactly, Laura. It's all about the cost of being wrong. Stale social media posts are fine; stale bank records are a legal and financial disaster.
Brian, in financial tech, we usually prioritize accuracy over a few extra milliseconds of latency. Using a CP database ensures that we prevent double-spending or overdrafts. While users love speed, they hate incorrect account balances even more. We usually optimize the network layer to keep that consensus-driven latency as low as possible for the end user.