The Dual Write Problem in NoSQL: MongoDB, DynamoDB, and Cassandra
Scenario context
NoSQL databases trade cross-entity atomicity for scale β and every database draws that atomicity boundary in a different place.
π― System Scenario & Requirements
System Goal
NoSQL databases trade cross-entity atomicity for scale β and every database draws that atomicity boundary in a different place.
Actors & Components
- Application or API tier
- Core service under design
- Operator or SRE observer
Functional Requirements
- NoSQL databases trade cross-entity atomicity for scale β and every database draws that atomicity boundary in a different place.
- MongoDB's boundary is the document (pre-4.0) or the replica set (4.0+ multi-doc transactions).
- DynamoDB's boundary is a single TransactWriteItems call, with failure modes that silently burn throughput.
Constraints & Assumptions
- The source does not isolate a separate failure mode.
- Limits that matter for the scenario are called out in the stage decisions above.
β‘ Execution Stages & Decision Trace
Stage 1 β End-to-end outcome
After working through the stages, you should be able to explain: - NoSQL does not mean no consistency β it means you manage consistency explicitly.
- Relational databases enforce consistency as a default through foreign keys, transaction isolation, and constraint checking.
Deep Dive
Scenario context
NoSQL databases trade cross-entity atomicity for scale β and every database draws that atomicity boundary in a different place. MongoDB's boundary is the document (pre-4.0) or the replica set (4.0+ multi-doc transactions). DynamoDB's boundary is a single TransactWriteItems call, with failure modes that silently burn throughput. Cassandra's boundary is the partition key. Write across any of these boundaries withoutβ¦
This walkthrough focuses on Scenario context.
Before making a design choice, clarify:
- NoSQL databases trade cross-entity atomicity for scale β and every database draws that atomicity boundary in a different place.
- MongoDB's boundary is the document (pre-4.0) or the replica set (4.0+ multi-doc transactions).
- DynamoDB's boundary is a single TransactWriteItems call, with failure modes that silently burn throughput.
Concepts in play: consistency-replication, database-indexing, transaction-isolation-distributed-acid, btree-vs-lsmtree
Stage 1 β End-to-end outcome
- After working through the stages, you should be able to explain: - NoSQL does not mean no consistency β it means you manage consistency explicitly.
- Relational databases enforce consistency as a default through foreign keys, transaction isolation, and constraint checking.
Observable outcome: - Relational databases enforce consistency as a default through foreign keys, transaction isolation, and constraint checking.
End-to-end outcome
After working through the stages, you should be able to explain:
- NoSQL does not mean no consistency β it means you manage consistency explicitly.
- Relational databases enforce consistency as a default through foreign keys, transaction isolation, and constraint checking.
Alternatives considered
Alternatives considered
The source focuses on one primary design.
Failure and degraded modes
Failure and degraded modes
- Detection: The source does not isolate a separate failure mode.
- User or operator impact: The source does not isolate a separate failure mode.
Key learnings
- NoSQL does not mean no consistency β it means you manage consistency explicitly.
- Relational databases enforce consistency as a default through foreign keys, transaction isolation, and constraint checking.
- After working through the stages, you should be able to explain: - NoSQL does not mean no consistency β it means you manage consistency explicitly.
