ACID Compliance

ACID compliance is a set of database characteristics consisting of Atomicity, Consistency, Isolation, and Durability that ensure that database transactions are completed efficiently.

If a database fulfills the aspects of ACID compliance, it is known to be ACID-compliant.

  • Atomicity: database transactions, also known as atoms, are capable of being broken down into smaller parts ensuring integrity of the entire database transaction.
  • Consistency: database transactions follow appropriate data validation rules and only data that satisfies the validation rules are written into the database.
  • Isolation: database transactions are capable of being concurrently processed with no conflicts.
  • Durability: data transactions ensure that the data is saved.

MongoDB

MongoDB is ACID-compliant from 4.0 version and onward.

From version 4.0 onward, MongoDB started providing multi-document ACID transactions and in 2019 extended to distributed multi-document transactions. With ACID transactions, MongoDB allows for multiple document updates that are atomic, consistent, isolated, and durable:

  • MongoDB ensures atomicity because transactions are completely processed and does not allow for partial completion of transactions.
  • MongoDB ensures for consistency because all writes go towards the MongoDB server ensuring single server consistency. With multi-document ACID transactions, you ensure consistency across multiple document transactions.
  • MongoDB ensures for isolation with locking mechanisms and using multi-document ACID transactions.
  • MongoDB ensures durability by recording the disk location and bytes changed for each write in a journal. So, if a system fails, MongoDB can reference that journal and restore the MongoDB system.

MySQL

MySQL is ACID-compliant.

  • MySQL ensures atomicity because MySQL only reflects changes from a transaction when the transaction is complete.
  • MySQL ensures consistency by logging all database changes and ensures the possibility of recovery to a previous state. MySQL also has locking mechanisms in order to control committed or rolled back transactions.
  • MySQL ensures isolation by controlling the traffic flow of transactions by maintaining the isolated processes of individual programs.
  • MySQL ensures durability because it by maintaining logs of previous database states during a transaction. In the event of a system failure, you can recover your MySQL database at a certain state ensuring durability.

PostgreSQL

PostgreSQL is ACID-compliant.

  • PostgreSQL ensures atomicity by either fully completing or failing transactions.
  • PostgreSQL ensures consistency because your database rolls back all changes when the transaction fails in order to keep data consistent.
  • PostgreSQL ensures isolation because transactions are kept separated from each other and ensures that transactions previously are completed before the next transaction goes through.
  • PostgreSQL ensures durability because the database logs changes and you can recover the database from a previous state in case your server fails.

Redis

Redis is not completely ACID-compliant because it does not satisfy consistency nor durability.

  • Redis ensures atomicity because you cannot go to the next transaction till your previous transactions are fully completed.
  • Redis does not guarantee consistency because Redis is at risk of losing writes.
  • Redis ensures isolation because transactions are kept separated from each other and ensure that transactions previously are completed before the next transaction goes through.
  • Redis cannot guarantee durability, but when you enable appendonly this may increase your Redis database’s durability while sacrificing performance.