Pages

ACID vs BASE: Understanding the Transaction Models




When we talk about software, data and how they are organized, we should consider the fact that they are many flavors available in the market
 
Distributed systems came into this world with the objective of provide scalability and performance, factors that monolithic systems in general struggle to provide. With this approach in mind and the necessity of manage a huge amount of data, they were some theorems created. One of the most famous is the CAP Theorem.
 
 

 
Created by Eric Allan Brewer, this theorem is focused on distributed data store, in a way that it stress that you should choose two of these three factors (because it is virtually impossible getting the best of the three). Another thing is that it is basically impossible getting CA in a distributed system, taking in consideration that these kind of systems rely in communication (any breakdown will affect this factor). Keep this in mind and let's talk about ACID and BASE.

 
ACID
 
  • Atomicity: this is the concept of "all or nothing" where each transaction is treated as a single unit. During the processes that occurring in that transaction, if any error appears, the entire process is canceled (or rolled-back).
  •  Consistency: it guarantees that there will be mechanisms, like triggers, constraints, PK/FK relationships to guarantee that data is consistency.
  • Isolation: it ensures that no transaction will affect or being affected by another, so it's safe to rollback the current transaction without creating any data problem.
  • Durability: once a transaction is committed, it will remain in the system, even it one crash occurs immediately after this commit. No data is lost.

There is a common sense in the community that business-critical systems that require reliability and immediate consistency should use this ACID model. Example: money transfer. However, we can face some problems related to scaling, complexity and loss of performance during time (probably as a consequence of the previous factor, complexity).

The databases that are compliant with ACID concepts are: Oracle, SQL Server, Postgres, MySQL, MariaDB, RavenDB, Neo4j and most graph databases.


 
 
BASE
 
  • Basically Available: it doesn't guarantee that data will be available, however there is a guarantee that the system will be operational.
  • Soft State: because of the eventual consistency model, it enforces that data can be changed during time, even it you haven't changed it right now.
  • Eventually Consistency: consistency will be achieved in the future.
 
BASE data stores are leverage performance, elasticity, availability, scale despite of guaranteed consistency (specially at write time).

The databases that are compliant with BASE are almost all NoSQL in the market.
 


WHAT TO CHOOSE?
 
The answer you probably know: it depends on the business requirements. There is no silver bullet, so choose what your business needs, taking in consideration that you cannot have everything in a perfect way, but you can be happy with part of everything.


----------------------------------------------------------------------------------------------------

Fabio Ono

No comments:

Post a Comment