ACID
Four guarantees for database transactions: Atomicity (all or nothing), Consistency (valid states only), Isolation (no interference), Durability (changes persist).
What is ACID?
In short
ACID is a set of four guarantees that database transactions provide so your data stays correct even when things go wrong: Atomicity (all the steps in a transaction happen or none do), Consistency (every committed transaction leaves the database in a valid state), Isolation (concurrent transactions don't see each other's half-finished work), and Durability (once a transaction commits, its changes survive crashes and power loss).
What ACID actually means
ACID describes four properties a database promises about a transaction, which is a group of reads and writes treated as one unit. The classic example is a bank transfer: subtract 100 from account A and add 100 to account B. Those two writes must succeed or fail together. If the system credits B but crashes before debiting A, you just printed money.
Atomicity means a transaction is all-or-nothing. If any step fails, the database rolls back every change so it looks like the transaction never started. There is no partial result left behind.
Consistency means the transaction moves the database from one valid state to another. Rules like foreign keys, unique constraints, and check constraints are never violated by a committed transaction. Part of this is on the database and part is on the application writing correct logic.
Isolation means transactions running at the same time do not corrupt each other. Even though the database may run thousands of them concurrently, each one behaves as if it had the database to itself. Durability means once you get the commit confirmation, the data is permanently stored and will survive a crash, a restart, or a power cut a millisecond later.
How databases actually enforce it
Atomicity and durability are usually handled by a write-ahead log (WAL). Before changing the actual data pages, the database appends a record of the change to a log file and flushes it to disk. PostgreSQL, MySQL with InnoDB, and SQLite all do this. If the server dies mid-transaction, on restart it replays committed log records and discards uncommitted ones, so the database recovers to a clean state.
Durability specifically depends on that flush hitting stable storage. This is why the famous fsync setting matters: if you let writes sit in an OS buffer for speed, a power cut can lose committed data. Strict durability waits for disk confirmation, which is slower but honest.
Isolation is enforced with locking or with multi-version concurrency control (MVCC). PostgreSQL and Oracle use MVCC, where each transaction reads a consistent snapshot of the data and writers create new row versions instead of blocking readers. The SQL standard defines four isolation levels (read uncommitted, read committed, repeatable read, serializable) that trade strictness for concurrency. Read committed is the common default; serializable is the strongest and prevents anomalies like phantom reads at the cost of throughput.
When to use it and the trade-offs
Reach for full ACID whenever correctness of the data matters more than raw speed: money movement, inventory counts, order processing, ticket booking, anything where a double-spend or a lost write is a real bug with real cost. Relational databases give you these guarantees by default, which is a big reason banks and ledgers run on them.
The cost is performance and scaling. Strong isolation requires coordination, and that coordination gets expensive across many machines. A single Postgres node enforces ACID cheaply, but spreading one transaction across servers in different regions means network round trips and locking that can stall under load.
This is the tension behind NoSQL and the BASE model (Basically Available, Soft state, Eventually consistent). Systems like early DynamoDB and Cassandra relaxed isolation and immediate consistency to get higher availability and horizontal scale. The industry has since swung back: many distributed databases now offer ACID transactions again, just with more engineering behind them. Pick based on your workload, not fashion.
A concrete example
Imagine a checkout. You wrap three statements in one transaction: insert an order row, decrement the product stock count, and insert a payment record. Atomicity guarantees that if the payment insert fails, the order and the stock change both roll back, so you never ship a product you never charged for.
Isolation matters here when two shoppers buy the last unit at the same time. Without it, both transactions could read stock as 1, both decrement to 0, and you oversell. With proper isolation (a row lock or a serializable transaction), the second buyer is forced to wait and then sees stock as 0, so they get an out-of-stock error instead of a phantom order.
Durability is the final promise: after the database returns COMMIT, your service can safely tell the customer the order is placed. Even if the server loses power one millisecond later, the order is on disk in the WAL and will be there when the machine comes back.
Where it is used in production
PostgreSQL
Fully ACID-compliant by default; uses a write-ahead log for atomicity and durability and MVCC for isolation across concurrent transactions.
MySQL (InnoDB)
The InnoDB storage engine provides ACID transactions with row-level locking and a redo log; powering ledgers and order systems at companies like Booking.com.
Amazon DynamoDB
Started as a BASE eventually-consistent store, then added ACID transactions in 2018 so apps can update multiple items atomically without giving up its scale.
Google Spanner
A globally distributed SQL database that keeps full ACID across data centers using synchronized TrueTime clocks; backs Google Ads and other money-critical systems.
Frequently asked questions
- What does ACID stand for?
- Atomicity, Consistency, Isolation, and Durability. Together they are the four guarantees a database makes about a transaction so your data stays correct even during crashes or concurrent access.
- What is the difference between ACID and BASE?
- ACID prioritizes correctness with strong consistency and isolation, common in relational databases. BASE (Basically Available, Soft state, Eventually consistent) relaxes those guarantees to get higher availability and easier horizontal scaling, common in NoSQL systems. ACID gives you immediate correctness; BASE gives you scale and accepts that data converges to consistency over a short delay.
- Do NoSQL databases support ACID?
- Many now do, at least partially. MongoDB added multi-document ACID transactions in version 4.0, and DynamoDB added transactions in 2018. Older NoSQL designs guaranteed atomicity only for a single record, so check the specific database and version before relying on multi-record transactions.
- Which ACID property is hardest to guarantee in a distributed system?
- Isolation, and to a degree consistency, because they require coordination between machines. Enforcing that concurrent transactions across many nodes behave as if they ran one at a time needs locking or consensus, which adds network round trips and limits throughput. That coordination cost is exactly why distributed databases like Spanner are hard to build.
- What is an isolation level?
- It is a setting that controls how strictly the database keeps concurrent transactions from interfering. The SQL standard defines four: read uncommitted, read committed, repeatable read, and serializable. Higher levels prevent more anomalies like dirty reads and phantom reads but reduce concurrency. Read committed is a frequent default; serializable is the safest and slowest.
Learn ACID hands-on
This page explains the idea. The full lesson lets you step through the ring as servers join and leave, read the implementation, and check yourself with a quiz. It is one of 760+ lessons in the System Design Masterclass, from your first API call to distributed consensus. Eleven Foundation lessons are free, no signup. Lifetime access is ₹499 in India or $7.99 worldwide, one payment, no subscription.
Related lessons
Lessons that touch on ACID as part of a larger topic.
Design a Payment System
Design a payment processing system - ACID transactions, idempotency, reconciliation, retry strategies, and the saga pattern for distributed payments
capstone · capstone
NewSQL Databases
Distributed SQL databases that promise the scalability of NoSQL with the ACID guarantees of traditional SQL. CockroachDB, Google Spanner, and the NewSQL movement
intermediate · database types storage
ACID Properties
Database transaction guarantees that keep your data correct
foundation · core fundamentals
See also
Related glossary terms you might want to look up next.
BASE
An alternative to ACID for distributed systems: Basically Available, Soft state, Eventually consistent. Trades strong consistency for availability.
SQL
Structured Query Language for managing relational databases. Tables, rows, columns, and powerful joins to query related data.
Two-Phase Commit
A protocol ensuring all nodes in a distributed transaction either commit or abort together. Phase 1: prepare (vote). Phase 2: commit or rollback.
Database
An organized collection of data that can be easily accessed, managed, and updated. The backbone of almost every application.
NoSQL
Databases that don't use traditional table-based relational models. Includes document stores, key-value, graph, and column-family databases.
Sharding
Splitting a database into smaller pieces (shards) distributed across multiple servers. Each shard holds a subset of the data.