Skip to main content

Consistency, transactions, availability

 

Consistency, Transactions, and Availability


1. Consistency

Meaning

Consistency means all users see the same data at the same time after an update.

In NoSQL systems:

  • Consistency can be strong or eventual

  • Many NoSQL databases follow eventual consistency

Consistency in MongoDB

  • Primary node handles writes

  • Secondary nodes replicate data

  • There may be a small delay in replication

Types:

  • Strong consistency – Read from primary

  • Eventual consistency – Read from secondary

Advantages

  • Better performance

  • High scalability


2. Transactions

Meaning

A transaction is a group of operations executed as a single unit.

ACID Properties

  • Atomicity – All or nothing

  • Consistency – Valid data state

  • Isolation – No interference

  • Durability – Data is saved permanently

Transactions in MongoDB

  • Earlier: single-document atomicity

  • Now: supports multi-document ACID transactions

  • Works across collections and databases

Use Cases

  • Banking systems

  • Order processing

  • Inventory management


3. Availability

Meaning

Availability means the database remains accessible even during failures.

Availability in MongoDB

  • Achieved using replica sets

  • If primary fails:

    • Secondary becomes primary automatically

  • Minimal downtime

Benefits

  • Fault tolerance

  • High reliability


4. CAP Theorem (Related Concept)

CAP states a distributed system can provide only two of the three:

  • C – Consistency

  • A – Availability

  • P – Partition tolerance

MongoDB focuses on:

  • Consistency + Partition tolerance (CP)

  • Availability may reduce during network failure

Comments