Vetora logo
๐ŸงชFoundations

ACID vs BASE

ACID and BASE represent two contrasting philosophies for data consistency in databases. ACID guarantees strict transactional correctness; BASE accepts eventual consistency for higher availability and scalability. Understanding both is essential for choosing the right database model.

Overview

ACID and BASE are two contrasting models for how databases handle data consistency and transactional guarantees. ACID -- Atomicity, Consistency, Isolation, Durability -- has been the gold standard for relational databases since Jim Gray formalized transaction processing in the 1970s. Atomicity ensures that a transaction either completes entirely or has no effect. Consistency ensures that transactions move the database from one valid state to another, maintaining all defined constraints and invariants. Isolation ensures that concurrent transactions do not interfere with each other, as if they executed serially. Durability ensures that once a transaction commits, the data survives even hardware failures.

BASE -- Basically Available, Soft state, Eventually consistent -- emerged as an alternative philosophy driven by the needs of internet-scale systems in the early 2000s. When companies like Amazon, Google, and Facebook needed to serve millions of concurrent users across globally distributed infrastructure, strict ACID guarantees became a bottleneck. Synchronous replication for consistency added unacceptable latency. Distributed transactions across shards (two-phase commit) were fragile and slow. BASE accepts that data may be temporarily inconsistent across nodes (soft state) and that the system will converge to a consistent state given enough time (eventual consistency), in exchange for higher availability and lower latency. Basically Available means the system guarantees a response to every request, even if the data is not yet consistent.

The industry narrative has evolved beyond a simple ACID-vs-BASE dichotomy. In the early NoSQL era (2008-2015), the prevailing wisdom was that you must sacrifice ACID to achieve distributed scale. Systems like Cassandra, DynamoDB, and MongoDB (in early versions) embraced BASE as a deliberate design choice. However, the NewSQL movement (starting around 2012) demonstrated that ACID guarantees could be maintained at distributed scale using consensus protocols like Raft and Paxos. CockroachDB provides serializable isolation across distributed nodes using Raft. Google Spanner provides external consistency (stronger than serializable) across global data centers using TrueTime. These systems pay a latency cost for strong guarantees but prove that ACID and distribution are not mutually exclusive.

Choosing between ACID and BASE depends on the specific consistency requirements of each data type in your system. Financial transactions, inventory management, and user account operations typically require ACID because incorrect intermediate states have real business consequences -- double-charging a credit card, overselling inventory, or losing an account update. Social media feeds, product recommendations, analytics dashboards, and session data can tolerate BASE because briefly stale data has minimal business impact and the performance benefits are substantial. Many production systems use both: an ACID relational database for core transactional data and a BASE NoSQL store for high-throughput, eventually-consistent workloads.

Key Points
  • 1ACID's Atomicity guarantees all-or-nothing transactions: if any part of a transaction fails, the entire transaction is rolled back. This prevents partial updates that leave data in an inconsistent state, like debiting one account without crediting another.
  • 2ACID's Isolation property has multiple levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable), each with different performance and correctness trade-offs. Serializable is the strongest but most expensive; most databases default to Read Committed.
  • 3BASE's 'eventually consistent' means that if no new updates are made to a data item, all replicas will converge to the same value. The convergence window is typically milliseconds to seconds, but under heavy load or network issues it can be longer.
  • 4Two-phase commit (2PC), the traditional mechanism for distributed ACID transactions, is blocking and fragile -- if the coordinator crashes during the commit phase, participants are stuck waiting. This limitation drove the adoption of BASE for distributed systems.
  • 5NewSQL databases (CockroachDB, Spanner, TiDB) achieve ACID at distributed scale using consensus protocols (Raft, Paxos) instead of 2PC. They pay higher latency per transaction but eliminate the need to choose between consistency and distribution.
  • 6Many systems combine ACID and BASE in a polyglot persistence architecture: PostgreSQL for orders and payments (ACID), Cassandra for user activity feeds (BASE), and Redis for session state (BASE with optional persistence).
Simple Example

The Bank Transfer Analogy

Consider transferring $100 from Account A to Account B. With ACID, the database guarantees that both the debit from A and the credit to B happen as one atomic unit -- if the system crashes after the debit but before the credit, the entire transaction is rolled back and no money is lost. With BASE, the debit and credit might happen at slightly different times on different nodes. For a brief moment, the $100 might appear to vanish (debited from A but not yet credited to B) or be duplicated (credited to B before being debited from A). The system will eventually converge to the correct state, but the intermediate inconsistency makes BASE unsuitable for financial operations where every cent must be accounted for at every moment.

Real-World Examples

PostgreSQL

PostgreSQL is a fully ACID-compliant relational database, providing serializable isolation via Serializable Snapshot Isolation (SSI). It uses Write-Ahead Logging (WAL) for durability, MVCC for concurrent transaction isolation, and constraint enforcement for consistency. PostgreSQL is the default choice for workloads that require transactional correctness -- financial systems, e-commerce orders, and user account management.

Apache Cassandra

Cassandra is a BASE system designed for write-heavy, globally distributed workloads. It uses tunable consistency (ONE, QUORUM, ALL) to let developers choose their position on the consistency-availability spectrum per query. By default, Cassandra provides eventual consistency with last-writer-wins conflict resolution. It sacrifices ACID properties like isolation and atomicity across partitions in exchange for linear write scalability and multi-datacenter availability.

CockroachDB

CockroachDB is a NewSQL database that provides full ACID guarantees -- including serializable isolation -- across a distributed, horizontally-sharded architecture. It uses the Raft consensus protocol to replicate data across nodes, ensuring that committed transactions survive node failures. CockroachDB demonstrates that ACID at distributed scale is achievable, though with higher per-transaction latency (typically 10-50ms for cross-range writes) compared to single-node PostgreSQL.

Trade-Offs
AspectDescription
Correctness vs PerformanceACID guarantees strict correctness but imposes performance overhead: locking for isolation, synchronous writes for durability, and constraint checking for consistency. BASE trades correctness during a convergence window for significantly higher throughput and lower latency, which can be a 10-100x difference for write-heavy workloads.
Scalability CeilingTraditional ACID databases on a single node have a vertical scaling ceiling. Distributed ACID (NewSQL) removes this ceiling but adds per-transaction latency for consensus. BASE systems scale horizontally with minimal coordination overhead, making them the natural choice for write-heavy workloads exceeding millions of operations per second.
Developer ComplexityACID simplifies application code because the database handles rollbacks, isolation, and constraint enforcement. BASE pushes complexity to the application layer: developers must handle eventual consistency, idempotency, conflict resolution, and compensating transactions. The reduced database complexity comes at the cost of increased application complexity.
Failure RecoveryACID databases recover cleanly from crashes by replaying the write-ahead log, guaranteeing that committed transactions survive and uncommitted ones are rolled back. BASE systems must run anti-entropy processes (read repair, merkle trees, hinted handoff) to detect and resolve inconsistencies after failures, which adds operational complexity.
Case Study

Uber's Migration from PostgreSQL to Schemaless (and Back)

Scenario

Uber initially ran on PostgreSQL for its core trip and driver data. As ride volume grew to millions of trips per day across hundreds of cities, the single PostgreSQL instance became a bottleneck. Write-amplification from PostgreSQL's MVCC implementation and the complexity of sharding a fully ACID database led to performance degradation and operational challenges.

Solution

Uber built Schemaless, a custom BASE datastore on top of MySQL that provided eventual consistency and horizontal write scalability. Trip data was sharded by city and time range. Schemaless sacrificed joins, foreign keys, and multi-row transactions (ACID properties) in exchange for append-only writes and linear scalability. For operations requiring consistency (payment settlement), Uber used a separate ACID-compliant system with idempotency keys and compensating transactions.

Outcome

Schemaless scaled to handle billions of rows and millions of writes per second across Uber's global infrastructure. The hybrid approach -- BASE for high-volume trip data, ACID for financial operations -- allowed Uber to apply each model where it was most appropriate. However, the complexity of managing eventual consistency in application code was significant, and Uber has since explored CockroachDB (ACID at scale) for workloads where strong consistency simplifies application logic.

Common Mistakes
  • โš Assuming BASE means 'no guarantees.' BASE systems do converge to consistency -- they are not randomly inconsistent. The convergence window is typically milliseconds under normal conditions. 'Eventually consistent' is a defined property with measurable latency, not a lack of guarantees.
  • โš Using BASE for financial transactions without compensating mechanisms. Eventual consistency means money can appear to be temporarily duplicated or lost. Financial operations need ACID guarantees or, at minimum, carefully designed idempotency and reconciliation processes.
  • โš Over-indexing on ACID when it is not needed. Using serializable isolation for a read-heavy product catalog or social feed wastes significant performance. Not every table in your system needs the strongest consistency model.
  • โš Confusing ACID's 'Consistency' with CAP's 'Consistency.' ACID consistency means maintaining database invariants (foreign keys, unique constraints, check constraints). CAP consistency means linearizability -- every read returns the latest write. They are fundamentally different properties with the same word.
Related Concepts

See ACID vs BASE in action

Explore system design templates that use acid vs base and run traffic simulations to see how these concepts perform under real load.

Browse Templates

Compare ACID transactions vs BASE in an e-commerce system

Metrics to watch
transaction_success_ratep99_latency_msthroughput_rpserror_rate_pct
Run Simulation
Test Your Understanding

1What does the 'I' in ACID stand for, and what does it guarantee?

2Why did large internet companies adopt BASE over ACID for many workloads?

3Which statement about NewSQL databases is correct?

Deeper Reading