Build a document store (MongoDB-style)

No scenes authored for this problem yet.

About Build a document store (MongoDB-style)

Schemaless documents that still behave like a database. Build a system that stores JSON/BSON natively, ships replica sets with primary elections, shards a collection by key range or hash, and keeps secondary indexes consistent under write — and feel exactly where 'flexible schema' turns into 'silent inconsistency'.

Difficulty
intermediate
Time
about 85 minutes
Stages
9
Topic
Storage Engines & Databases

How this problem is worked

Nine stages, from what the thing is for to how it compares with the real implementations. Each asks one question, and the simulator runs the architecture you draw against the requirements you wrote.

  1. 01Purpose & invariantsWhat is this for, and what must always be true of it?
  2. 02Workload characterizationWho writes, who reads, and in what shapes?
  3. 03Data model & on-disk formatWhat does the data look like at rest?
  4. 04Core algorithmsHow do the write path and the read path actually work?
  5. 05Distribution & replicationHow does this scale out and survive losing a machine?
  6. 06Consistency & correctnessUnder concurrency and failure, what is guaranteed?
  7. 07Failure modes & recoveryWhat actually happens when each part fails?
  8. 08Operational characteristicsCan a human run this at three in the morning?
  9. 09Trade-offs & comparisonWhere does this sit against the alternatives?

Primary sources for this problem

  • MongoDB Architecture Guide (mongodb.com whitepaper)
  • MongoDB Manual — Replica sets, Sharding, Read/Write concerns
  • WiredTiger architecture doc (storage engine internals)
  • MongoDB blog — Causal consistency in MongoDB 3.6+
  • Kleppmann — Designing Data-Intensive Applications (Ch. 2 — document vs relational)
  • Jepsen — MongoDB analyses (multiple)

More in Storage Engines & Databases

Open the box every design diagram labels "DB": pages, logs, LSM trees, wide-column, documents, graphs and columnar scans, built from scratch.

Browse the full problem catalog, or see what the simulator does and does not model.