Skip to main content

Why NoSQL Sacrifices ACID for High Availability

🎯 The Question

"Why do distributed NoSQL databases (like DynamoDB, Cassandra, MongoDB) relax ACID guarantees and adopt Eventual Consistency (BASE)? What does the CAP Theorem dictate during network splits?"


⚡ 30-Second Elevator Pitch

In a single-node database, you can have both 100% Consistency and 100% Availability. But distributed systems span multiple servers across networks, where Network Partitions (PP) are inevitable (cables get cut, switches fail, latency spikes).

The CAP Theorem proves that when a Network Partition occurs, you MUST choose:

  1. Consistency (CP): Reject incoming writes to prevent stale data. The system guarantees correctness, but sacrifices availability (returns error/downtime).
  2. Availability (AP): Accept writes on both sides of the network split. The system guarantees 100% uptime, but sacrifices strict consistency (data syncs eventually).

High-scale consumer apps (Amazon Cart, Social Media) prioritize Availability over Consistency because 1 minute of downtime costs millions of dollars.


🧠 Under-the-Hood: The CAP Theorem Trade-off


🔬 ACID vs. BASE Model

ACID (Traditional SQL - CP)BASE (Distributed NoSQL - AP)
Atomicity: All or nothing transactionBasically Available: System stays up during failures
Consistency: Strict immediate constraint enforcementSoft State: Data state may change without input
Isolation: Transactions isolated from each otherEventual Consistency: Replicas converge over time
Durability: Committed data is never lost

📌 Comparison Matrix: CP vs. AP Distributed Systems

PropertyCP Systems (Consistency + Partition Tolerance)AP Systems (Availability + Partition Tolerance)
Network Split ResponseReturns error or blocks until syncReturns success immediately using local node state
Data GuaranteeLinearizable / Immediate ConsistencyEventual Consistency (Read-your-writes possible)
Conflict ResolutionTwo-Phase Commit (2PC) / Raft consensusLast-Write-Wins (LWW) / Vector Clocks
ExamplesPostgreSQL (Single), Spanner, Etcd, ZooKeeperCassandra, DynamoDB, Couchbase, Riak

💡 What Interviewers Ask Next (Follow-Up Traps)

  1. "What is the PACELC Theorem?"

    • Answer: PACELC extends CAP: If Partitioned (PP), choose between Availability (AA) or Consistency (CC); Else (EE), choose between Latency (LL) or Consistency (CC). It describes database trade-offs during normal operating conditions when no network failure exists.
  2. "What is Tunable Consistency in Apache Cassandra?"

    • Answer: Cassandra allows developers to configure consistency per query using quorum math: extReadQuorum(R)+extWriteQuorum(W)>extReplicationFactor(N) ext{Read Quorum } (R) + ext{Write Quorum } (W) > ext{Replication Factor } (N) If R+W>NR + W > N, the application is guaranteed to read the latest written value (Strong Consistency), balancing AP and CP dynamically.

Placement & Interview Takeaway

Interview Answer: Under the CAP theorem, distributed systems cannot prevent network partitions. When a partition occurs, databases must choose between returning errors to guarantee consistency (CP) or accepting writes with eventual consistency to guarantee availability (AP).


📺 Video Explanation

💬

Discussion & Doubts