Consistência em Sistemas Distribuídos NoSQL
Referencias:
[1] uma boa introduçao e comparação de SQL x Nosql
https://medium.com/system-design-blog/sql-vs-nosql-databases-6896a8cb1800
[2] detailed review and comparisons of Relational SQL x NoSQL
https://medium.com/nerd-for-tech/sql-or-nosql-which-one-to-choose-757147a559f8
Três requisitos desejáveis em Sistemas Distribuídos NoSQL não podem ser obtidos
simultâneamente:
Consistência, Disponibilidade e Tolerância a Particionamentos.
Este é o famoso "Teorema CAP" de Eric Brewers que afirma:
"We can only achieve at most two out of three guarantees for a database:
Consistency, Availability, and Partition Tolerance".
Texto retirado de [1]:
ACID properties ensure that once a transaction is complete, It’s data is consistent and stable on the disk. It follows a strong consistency model.
NoSQL BASE Consistency Model:
BASE stands for BA (Basic Availability), S (Soft-State) and E (Eventual Consistency).
BASE provides eventual consistency over immediate consistency for scalability, availability, and resiliency.
- Basic Availability (BA) :
The database is available most of the time.
- Soft-State ( S ) :
Stores don’t have to write consistent. No different replicas have to be mutually consistent all the time.
- Eventual Consistency ( E ):
Once a write completes and there is no write after that then all reads after the write will receive last updated value.
Databases with BASE consistency model ( NoSQL databases) prefers availability over the consistency of replicated data at write time.
BASE is less strict than ACID. Data will be consistent in the future either at the read time or it will be always consistent.
Types of NoSQL Databases
- Key-Value Store:
Every item in the database is stored as an attribute name
( or “key”) together with its value.
Redis, AWS DynamoDB, Riak are the most popular databases in this category.
- Wide-Column Store:
These kinds of NoSQL databases stores data together as columns instead of rows and are optimized for queries over large datasets.
The most popular are Cassandra and HBase.
- Document Store:
Pairs each key with a complex data structure known as a document. A document can contain different key-value pairs or even nested documents.
MongoDB is the most popular document store database.
- Graph Store:
Are used to store info about networks such as a social networks.
Neo4J and HypergraphDB are popular ones.