Consistency and Availability
1. Consistency
Meaning
Consistency means that all users see the same data at the same time after an update.
In distributed NoSQL databases, full consistency at all times is difficult, so systems use tunable consistency.
Consistency in Cassandra
Cassandra provides tunable consistency, meaning the user can choose the level of consistency required.
Common Consistency Levels
-
ONE – Data written/read from one node
-
QUORUM – Majority of replica nodes respond
-
ALL – All replica nodes respond
Advantages
-
Flexibility to balance performance and accuracy
-
Suitable for different application needs
2. Availability
Meaning
Availability means the database remains operational and accessible even if some nodes fail.
Availability in Cassandra
-
Uses peer-to-peer architecture
-
No master node → no single point of failure
-
Data is replicated across nodes
-
Requests can be served by any available node
Benefits
-
Continuous uptime
-
Automatic failover
-
High fault tolerance
3. Consistency vs Availability (CAP Theorem)
CAP theorem states that a distributed system can provide only two out of three:
-
C – Consistency
-
A – Availability
-
P – Partition Tolerance
Cassandra follows
-
Availability + Partition Tolerance (AP)
-
Consistency can be adjusted as required
4. Comparison Table
| Aspect | Cassandra |
|---|---|
| Default consistency | Eventual |
| Consistency type | Tunable |
| Availability | Very high |
| Failure handling | Automatic |
5. Real-World Example
-
Social media likes count
-
Sensor data collection
-
Messaging systems
These applications prefer availability over strict consistency.
Comments
Post a Comment