Skip to the guide

Design a key-value store (like DynamoDB)

AdvancedCase study12 pages

You build the database itself: a service that stores items by key for thousands of tables, answers in a few milliseconds at any size, and never loses an item once it has said "saved". It's a bank's safe-deposit vault, where every box has a number and its contents are never allowed to go missing.

It's also asked as "design DynamoDB", "design Cassandra" or "design a distributed hash table". The closest case study is the Distributed cache, which spreads keys the same way but can lose them; here every copy and every failover has to keep them. Interviewers like it because "use DynamoDB" isn't an answer when DynamoDB is the question (Build vs buy).

Below is a full mock interview following the seven steps of the framework. You're the candidate: at each Guess before you read on, stop and answer first.

Step 1 · Clarify the features and cut the scope

Minutes 0–5 · How this step works

Interviewer: Design a key-value store like DynamoDB.

You: A managed service for many teams, or one cluster for one app?

Interviewer: A service. Thousands of tables.

You: Only get and put by key, or ranges too?

Interviewer: A partition key and an optional sort key, with queries over a range of sort keys inside one partition key.

You: Do clients need conditional writes, like "only if the version is still 7"? And transactions across items?

Interviewer: Conditional writes, yes. Transactions, no.

You: One region or several?

Interviewer: One region first. Multi-region if there's time.

You: Then I'll cover put, get, delete and query, conditional writes, replication and failover, repair, and splitting and moving partitions. Out: transactions, secondary indexes, backups as a product, and billing. OK?

Interviewer: Good.

Each answer shapes the design. Many tables mean per-table limits, and conditional writes need one order per item, which points to a leader per partition.

Step 2 · Non-functional requirements

Minutes 5–8 · How this step works

You: Say 2.5 million requests a second at peak: 2 million reads and 500,000 writes, about 1 million on average. Reads and writes under 10 ms at p99, measured at our front door. 99.99% available, about 4.3 minutes a month. An acknowledged write is never lost, even if a whole zone is. Reads are eventually consistent by default, a strongly consistent read returns the latest acknowledged write, and conditional writes never lose an update.