Design a distributed key-value store like DynamoDB

Quick Overview

Design a distributed key-value store with get, put and delete that grows to thousands of nodes and keeps serving traffic during network partitions. It tests partitioning and replication, tunable consistency, resolving concurrent writes, single-node storage design and recovery from node failures.

Design a distributed key-value store like DynamoDB

Company: MongoDB

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Other

Design a distributed key-value store similar to Amazon DynamoDB. Clients store and retrieve opaque values by key with three operations: `get(key)`, `put(key, value)` and `delete(key)`. The store runs on a large cluster of commodity servers, keeps serving reads and writes when servers fail or the network partitions, and scales by adding servers. Explain how a single node stores data, how keys are spread and replicated across nodes, what consistency clients get, how conflicting writes are handled, and how the cluster finds and recovers from failures. ```hint Placing keys on nodes Look for a key-to-node mapping where adding or removing one server moves only a small share of the keys, and think about what happens to load when servers differ in size. ``` ```hint Overlap between reads and writes With N copies of each key, count how many must acknowledge a write and how many must answer a read. What relation between those counts makes a read see the latest write, and what can still break it? ``` ```hint Diverging replicas Because writes keep landing during a partition, two replicas can accept different updates to the same key. Decide how a replica tells a newer version from a concurrent one before choosing how to merge them. ``` ### Constraints & Assumptions - The cluster grows incrementally to thousands of nodes and petabytes of data. - The cluster serves millions of requests per second. - `get` and `put` complete in single-digit milliseconds, under 10 ms at p99. - Every node has the same role. There is no master node. - During a network partition, availability comes before strong consistency, and eventual consistency is acceptable by default. ### Clarifying Questions to Ask - What are typical key and value sizes, and what is the read to write ratio? - Are all operations on a single key, or do we also need range scans, secondary indexes or multi-key transactions? - Is it acceptable for a read to return stale data or several conflicting versions, or do some callers need strongly consistent reads? - Does the cluster span several availability zones or data centers, and must it survive losing one? - Can clients know the cluster layout and route requests directly to nodes, or must every request go through a load balancer? ### What a Strong Answer Covers - Requirements and a rough capacity estimate that turn the scale targets into a node count and a per-node load. - A single-node storage engine with durable, fast writes, bounded read cost, and a delete mechanism that survives replication. - How keys are partitioned and replicated so load stays balanced, little data moves when nodes join or leave, and copies land on separate machines. - The consistency model: quorum sizes for reads and writes, what they do and do not guarantee, and how concurrent conflicting writes are detected and resolved. - Failure handling without a master: membership and failure detection, temporary outages, and repair of replicas that have drifted apart. ### Follow-up Questions - One key suddenly takes a large share of all traffic. How do you keep its replicas from being overwhelmed? - How do you place replicas so the store keeps serving reads and writes after losing a whole availability zone? - A client needs to read its own writes right after a put. What changes, and what does it cost? - What does last-write-wins lose compared with vector clocks, and when is it still the right choice?

Overview: Design a distributed key-value store with get, put and delete that grows to thousands of nodes and keeps serving traffic during network partitions. It tests partitioning and replication, tunable consistency, resolving concurrent writes, single-node storage design and recovery from node failures.

MongoDB logo
MongoDB
Nov 24, 2026
hardSoftware EngineerOtherSystem Design
0
0

Design a distributed key-value store similar to Amazon DynamoDB. Clients store and retrieve opaque values by key with three operations: get(key), put(key, value) and delete(key). The store runs on a large cluster of commodity servers, keeps serving reads and writes when servers fail or the network partitions, and scales by adding servers.

Explain how a single node stores data, how keys are spread and replicated across nodes, what consistency clients get, how conflicting writes are handled, and how the cluster finds and recovers from failures.

Constraints & Assumptions

  • The cluster grows incrementally to thousands of nodes and petabytes of data.
  • The cluster serves millions of requests per second.
  • get and put complete in single-digit milliseconds, under 10 ms at p99.
  • Every node has the same role. There is no master node.
  • During a network partition, availability comes before strong consistency, and eventual consistency is acceptable by default.

Clarifying Questions to Ask Guidance

  • What are typical key and value sizes, and what is the read to write ratio?
  • Are all operations on a single key, or do we also need range scans, secondary indexes or multi-key transactions?
  • Is it acceptable for a read to return stale data or several conflicting versions, or do some callers need strongly consistent reads?
  • Does the cluster span several availability zones or data centers, and must it survive losing one?
  • Can clients know the cluster layout and route requests directly to nodes, or must every request go through a load balancer?

What a Strong Answer Covers Guidance

  • Requirements and a rough capacity estimate that turn the scale targets into a node count and a per-node load.
  • A single-node storage engine with durable, fast writes, bounded read cost, and a delete mechanism that survives replication.
  • How keys are partitioned and replicated so load stays balanced, little data moves when nodes join or leave, and copies land on separate machines.
  • The consistency model: quorum sizes for reads and writes, what they do and do not guarantee, and how concurrent conflicting writes are detected and resolved.
  • Failure handling without a master: membership and failure detection, temporary outages, and repair of replicas that have drifted apart.

Follow-up Questions Guidance

  • One key suddenly takes a large share of all traffic. How do you keep its replicas from being overwhelmed?
  • How do you place replicas so the store keeps serving reads and writes after losing a whole availability zone?
  • A client needs to read its own writes right after a put. What changes, and what does it cost?
  • What does last-write-wins lose compared with vector clocks, and when is it still the right choice?