All Posts

BASE Theorem Explained: How it Stands Against ACID

ACID guarantees consistency. BASE guarantees availability. We explain the trade-offs between SQL...

Abstract AlgorithmsAbstract Algorithms
ยทยท5 min read
Share
Share on X / Twitter
Share on LinkedIn
Copy link

TLDR: ACID (Atomicity, Consistency, Isolation, Durability) is the gold standard for banking. BASE (Basically Available, Soft state, Eventual consistency) is the standard for social media. BASE intentionally sacrifices instant accuracy in exchange for high availability and horizontal scale.


๐Ÿ“– Why Your Bank and Twitter Run on Different Consistency Rules

When you transfer $100, you need a guarantee: the money leaves your account and lands in the recipient's account as one atomic operation. A partial success is worse than no operation at all. This is ACID.

When you post a tweet, you do not care if a user in Singapore sees it 500 ms later than a user in New York. What you care about is that the system stays up and the tweet eventually propagates everywhere. This is BASE.

The two models exist because of the CAP theorem: you cannot have strong consistency, perfect availability, AND partition tolerance at the same time. ACID systems (like PostgreSQL) choose consistency. BASE systems (like DynamoDB, Cassandra) choose availability.


๐Ÿ”ข ACID Refresher: The Four Promises of Relational Databases

PropertyMeaningExample
AtomicityAll-or-nothing. Either all operations in a transaction commit, or none do.Bank transfer: debit and credit both succeed or both roll back.
ConsistencyThe database always moves from one valid state to another โ€” no constraint violations.A column with NOT NULL constraint is never left empty.
IsolationConcurrent transactions behave as if they ran sequentially.Two users booking the last seat cannot both see it as available.
DurabilityOnce committed, data survives crashes.A PostgreSQL commit is written to the WAL before acknowledging.

โš™๏ธ BASE in Detail: The Three Properties Unpacked

B โ€” Basically Available

The system returns a response to every request, even if that response is stale or partial. Think of Amazon showing a product as "In Stock" based on the last known count, even if the live count hasn't propagated yet.

S โ€” Soft State

The state of the system may change over time even without new input, as consistency information propagates across nodes. The data is "in flux" during the window between a write and full propagation.

E โ€” Eventually Consistent

Given no new updates, the system will converge โ€” eventually โ€” to a consistent state across all replicas. The key word is eventually: it might be milliseconds, it might be seconds, but not guaranteed to be instant.

flowchart LR
    Client --> NodeA[Node A\nWrite X=5]
    NodeA --> NodeB[Node B\nX=5 propagates]
    NodeA --> NodeC[Node C\nX=5 propagates]
    NodeC --> StaleRead[Stale read\nX=3 for ~100ms]
    NodeB --> FreshRead[Fresh read\nX=5]

๐Ÿง  Eventual Consistency in Practice: The Shopping Cart Example

Amazon's Dynamo paper (2007) used the shopping cart as the canonical example.

  • You add "Red Shoes" to your cart on your phone.
  • You open your cart on your laptop 200 ms later.
  • The write hasn't propagated yet โ€” the laptop sees the old cart (no Red Shoes).
  • After ~500 ms, both devices show "Red Shoes."

The system chose availability (always respond) over strong consistency (always latest value). For a shopping cart, a brief stale view is acceptable. For a bank balance, it is not.


โš–๏ธ ACID vs BASE: Choosing the Right Trade-off

DimensionACIDBASE
ConsistencyStrong, immediateEventual
AvailabilityCan reject requests during partitionAlways responds
Write throughputLimited by lock and quorum overheadHigh โ€” local writes accepted immediately
Typical databasesPostgreSQL, MySQL, CockroachDBDynamoDB, Cassandra, MongoDB (tunable)
Best forFinance, inventory, bookingsSocial feeds, caches, shopping carts, analytics

Decision rule of thumb: If your data has money, seats, or contracts in it, lean toward ACID. If your data has likes, views, or preferences in it, BASE is usually fine.


๐ŸŒ BASE Systems You Use Every Day

  • Amazon DynamoDB: Eventual consistency by default; strongly consistent reads available with extra cost.
  • Apache Cassandra: Tunable consistency โ€” you choose per-query: ONE, QUORUM, or ALL.
  • Redis (cache-aside): Classic soft-state โ€” your cache is always slightly behind the source of truth.
  • DNS: The most widely used eventually consistent system on earth. A domain change can take up to 48 hours to propagate globally.

๐Ÿ“Œ Key Takeaways

  • BASE is the design philosophy behind highly available, horizontally scalable systems.
  • Basically Available: always respond, even if data is stale.
  • Soft State: data is in flux during propagation; eventual consistency is the target.
  • Eventually Consistent: all replicas converge, just not instantly.
  • Choose ACID for money, seats, or contracts; choose BASE for social, caching, or analytics.

๐Ÿงฉ Test Your Understanding

  1. What does "soft state" mean in the context of BASE?
  2. A user adds an item to their cart and checks out from a different device 1 second later. The item is missing. Which BASE property explains this?
  3. Can a system be partially ACID and partially BASE? Give an example.
  4. Why does DNS demonstrate eventual consistency?

Abstract Algorithms

Written by

Abstract Algorithms

@abstractalgorithms