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​

πŸš€ Level Up Your Engineering Mindset

Never Study in Isolation. Join Binary Dose.

Connect with fellow engineers, clear conceptual doubts, and get 2 visual breakdowns & engineering mental models daily across our community channels.

Discord
Official Hub

Discord Community

Start at #welcome-and-rules, say hello in #general-chat, clear doubts, and collaborate with engineers worldwide.

Join Discord Server→
⚑
Daily Knowledge Drops

Daily Visual Deep-Dives

Bite-sized system design schematics, core OS internals, and DSA intuition served right into your feeds every single day.

πŸ’‘Have handwritten notes, cheat-sheets, or want to publish a technical article?
Learn How to Contribute→