Skip to main content
AllDevToolsHub
Back to Glossary

ACID Properties

A set of properties (Atomicity, Consistency, Isolation, Durability) that guarantee database transactions are processed reliably.

Detailed Explanation

ACID is what ensures your bank transfer doesn't 'lose' money. Atomicity: the whole transaction succeeds or fails. Consistency: data remains valid according to all rules. Isolation: transactions don't interfere with each other. Durability: once committed, data survives even a system crash. Relational databases are built on ACID; many NoSQL databases trade some ACID guarantees for higher performance (BASE).

Quick Summary

ACID is the four-property contract that makes traditional databases trustworthy for money, inventory, and anything where partial updates would be catastrophic.

Key Takeaways

Key Takeaways

  • Atomicity: a transaction is all-or-nothing; no partial writes survive a crash mid-transaction.
  • Consistency: every committed transaction leaves the database in a valid state per its constraints.
  • Isolation: concurrent transactions appear to execute serially; choose an isolation level (Read Committed, Repeatable Read, Serializable) to trade safety vs. throughput.
  • Durability: once committed, data survives crashes, usually via write-ahead logs and `fsync`.
  • Most distributed databases offer ACID within a partition; cross-partition ACID is the hard, expensive case.
Use Cases

When to use it

  • Financial systems where partial transfers would be catastrophic.
  • Inventory and reservations where overselling has real cost.
  • Any "create user + send welcome email" flow where you don't want the row without the email row, or vice versa.
  • Choosing isolation level for high-throughput systems, most defaults (Read Committed) leak more anomalies than people expect.
Watch out

Common Mistakes

  • Assuming the default isolation level prevents lost updates and phantom reads, it usually doesn't.
  • Running long transactions that hold locks and block other writes.
  • Mixing application logic with transactions in a way that holds DB connections during slow external calls.
  • Treating eventual consistency as ACID-equivalent for use cases that actually need strong consistency.
FAQ

ACID Properties, Frequently Asked

What's the difference between ACID and BASE?

BASE (Basically Available, Soft state, Eventually consistent) is the looser model many NoSQL systems use to scale horizontally. ACID prioritizes correctness; BASE prioritizes availability and throughput. Real systems often need both, ACID for the financial core, BASE for activity feeds and search.

Which isolation level should I use?

Start with the database's default (usually Read Committed in PostgreSQL/MySQL, Snapshot in SQL Server). Move to Repeatable Read or Serializable for transactions where you've observed concurrency bugs. Don't blanket-Serializable everything, throughput drops sharply.