Loading...
System Design and AI Engineering, by Roni Das. 980 interactive lessons.
Start LearningSystem design interview guide
in this guide
7 parts open to everyone · 3 with a free account · 3 with the course
Interviewers reach for this problem because it cannot be answered by naming a product. You have to build up from first principles: how do you spread data across machines so it stays balanced (consistent hashing), how do you keep it available when machines die (replication and quorums), what happens when two replicas disagree (conflict resolution), and how do you keep single-key operations fast while the table grows without bound (partitioning and online resharding). It also rewards intellectual honesty, because the correct answers force you to admit real limits: the default read is eventually consistent, a bad partition key creates a hot partition that no amount of provisioned capacity fixes cleanly, and cross-partition transactions are expensive and constrained. It is one of the few questions where the CAP theorem stops being a slogan and becomes a concrete set of decisions you have to defend.
This page is the free part.
₹499 in India$49 everywhere elseonce, for the whole course
The System Design course covers the DynamoDB design across a run of lessons, not one page. These 4 alone are about 167 minutes of step-by-step reading, 2 of them with code you run in the browser, all with a quiz.
Live from the course bench
Real interview questions, live diagrams and measured lab results, pulled at random from the lessons. A new set every time you come back.
Always clarify these in the first 5 minutes of the interview. Do not start drawing boxes until both lists are agreed.
This guide is built on these 6 lessons. Each one teaches one piece of the DynamoDB (a distributed key-value store) design above, step by step.
Lifetime access for ₹499 in India or $49 elsewhere. Interactive diagrams, quizzes, and 20 capstone projects to practise on.
This one question is not enough for the interview.
Each question has why it is asked, a full answer, what the interviewer listens for, the follow-ups, the common mistakes and a diagram (268 diagrams in all). A PDF you keep, junior to staff level.
Two courses by the author of this page:
770 lessons · 18 free to read
₹499 in India · $49 elsewhere, once
Get System DesignYou own this course
210 lessons · 10 free to read
₹999 in India · $49 elsewhere, once
Get AI EngineeringYou own this course
Save your progress and get the interview checklist PDF
DynamoDB is built to return a point read or write in single-digit milliseconds no matter how large the table gets, and large tables can sustain millions of requests per second by spreading data and traffic across thousands of partitions on thousands of storage nodes. The trick is not any one clever algorithm. It is that the whole system is organized so that adding hardware adds throughput almost linearly, and so that no single request ever has to touch more than a handful of nodes. The interesting design questions are all about what you give up to get that: rich queries, cross-key transactions, and, by default, read-your-write freshness. Any specific throughput or latency number here is an industry-typical range or an illustration, not a measured AWS-internal figure.
DynamoDB is a managed distributed key-value and document store descended from the 2007 Amazon Dynamo paper. You address every item by a primary key, and the system hashes that key to decide which partition, and therefore which set of storage nodes, owns the item. Data is partitioned by consistent hashing and replicated to a small number of nodes (typically three) across separate availability zones, so a single node or even a whole zone can fail without losing data or availability. The original Dynamo was fully leaderless and used vector clocks with application-side conflict resolution, but production DynamoDB moved to a per-partition leader with quorum-style replication and a write-ahead log, which is simpler for developers to reason about. Reads come in two flavors: eventually consistent (cheap, may be slightly stale) and strongly consistent (routed to the leader replica). The hard design themes are all trade-offs: how you pick a partition key so load spreads evenly instead of creating a hot partition, how the system reshares and moves data online as tables grow, how secondary indexes are kept up to date asynchronously, and how global tables give you multi-region writes at the cost of last-writer-wins conflict resolution. DynamoDB leans toward availability and predictable latency over rich query power and strong global consistency.
Where it shows up
Asked at Amazon first and foremost, since Dynamo is their own paper and DynamoDB is their flagship NoSQL service, but the underlying design shows up everywhere: Google, Meta, Uber, Netflix, and any company that runs Cassandra, ScyllaDB, or Riak, all of which are direct descendants of the Dynamo paper. It appears both as a pure infrastructure question (design a distributed key-value store) and as a building block inside larger designs like shopping carts, session stores, feature stores, and metadata services.
Spec sheetDynamoDB (a distributed key-value store)
worked through below, with the maths
The hard parts of this design are taught step by step in the System Design course: Design a Key-Value Store, Quorum and Vector Clocks.
Design a distributed key-value store - LSM trees, compaction, consistent hashing, replication, tunable consistency, and failure detection.
Why quorum reads and writes stay consistent when R + W > N. A grid of every R and W pair for five replicas shows which ones are safe.
How vector clocks detect concurrent writes that Lamport timestamps miss. Includes a Python implementation and the Dynamo shopping cart example.
Consistency, Availability, Partition Tolerance, you can only pick two, and you must pick partition tolerance.
all part of
System Design Masterclass
770 lessons · about 283 hours · 18 free to read
₹499in India, by UPI
$49everywhere else, by PayPal
You own this course
Continue with Design a Key-Value Storepay once,
yours for life
Show your math. Pulling numbers from thin air signals you have not thought about the load.
Point-read/write latency
single-digit ms (typical)
An eventually consistent read served from an in-memory or local-SSD replica, or a write acknowledged after a quorum of local-zone replicas, is dominated by intra-datacenter network hops and a B-tree or LSM lookup. This is a design target of the service, not a per-request guarantee, so treat it as typical.
Item size limit
~400 KB per item
A key-value store caps item size so a single item cannot dominate a partition or a network buffer. DynamoDB's public documented limit is 400 KB including attribute names and values. Large blobs are expected to live in object storage with only a pointer in the item.
Per-partition throughput ceiling
~3000 reads/sec and ~1000 writes/sec per partition
Each physical partition is one unit of concurrency backed by a bounded slice of a node CPU, memory, and disk. Published DynamoDB guidance describes a per-partition ceiling on the order of 3000 read units and 1000 write units per second. A table exceeds this only by having many partitions, which is why key distribution matters.
Replication factor
3 replicas across 3 availability zones
Three copies in three failure domains is the standard durability-versus-cost point: it survives losing any one copy or one whole zone while keeping a majority quorum of two available. Derived from the general quorum model, matching DynamoDB's documented multi-AZ replication.
Partitions per large table
thousands (estimate)
If one partition holds on the order of 10 GB and caps at a few thousand ops/sec, then a petabyte-scale, million-op/sec table must be spread across many thousands of partitions. Derived by dividing total size and total throughput by per-partition limits.
Global table replication lag
typically sub-second (estimate)
Cross-region replication in global tables is asynchronous, so a write in one region propagates to others after a network and processing delay. Sub-second is the commonly cited typical figure, but it is a range that widens with distance and load, so it is an estimate.
A client issues an operation against a table, addressing an item by its primary key, and speaks to the service through a stateless request layer. The first job of that layer is routing: it takes the partition key, hashes it, and looks up which partition owns that hash range in the partition metadata. That lookup tells it which storage nodes hold the replicas for the item. The request router is not the source of truth for data; it is a thin, horizontally scalable tier whose only job is to authenticate the caller, check that the request stays within its allocated throughput (admission control), find the right partition, and forward the operation. Because routing is a pure function of the key plus a metadata map, you can run as many request routers as you need and any of them can serve any request. Data is partitioned by consistent hashing. The keyspace is a ring, each key hashes to a point on the ring, and each partition owns a contiguous arc of that ring. When a partition gets too big or too hot, it splits, and the metadata map is updated so future requests route to the new owners. Each partition is replicated, typically three ways, across separate availability zones so that the failure of a disk, a machine, or an entire zone never takes the data offline. Production DynamoDB designates one replica per partition as the leader. Writes go to the leader, which appends to a write-ahead log and replicates to the other members; a write is acknowledged once a quorum has durably accepted it. Strongly consistent reads are served by the leader, which knows it has the latest committed value, while eventually consistent reads can be served by any replica and may lag slightly. On each storage node, an item lives in a local storage engine, commonly a log-structured merge tree (LSM) or a B-tree, that turns random-looking key access into efficient sequential disk writes and indexed reads. Writes first hit a durable log and an in-memory structure, then get flushed and compacted in the background. This is what lets the node absorb a high write rate while still answering point reads quickly. Secondary indexes are maintained as their own partitioned structures that are updated asynchronously from the base table change stream, which is why a global secondary index is eventually consistent with the item you just wrote. Underneath all of this is a control plane that the data path does not sit on directly. It tracks node membership and health, decides when a partition should split or move, drives the actual data movement while the partition stays online, and updates the metadata map that the request routers consult. Membership and failure information propagate through a gossip-style mechanism in the original Dynamo design and through a more centralized, quorum-backed metadata service in production DynamoDB, but the principle is the same: the fast path stays simple and local, and the slow, global coordination is pushed off to a separate system that is not in the critical path of a get or a put.
In a real interview, sketch this on the whiteboard before diving into any single box.
Walk through each service. The interviewer wants to hear what each one owns, not just the names.
A stateless front-end tier that receives every operation, authenticates it, enforces the caller throughput allocation, hashes the partition key to find the owning partition, and forwards the request to the right storage nodes. For a write it targets the partition leader; for an eventually consistent read it can target any replica. Because it holds no durable state, it scales out freely and any router can handle any key.
The authoritative mapping from hash ranges on the ring to the partitions and storage nodes that own them. Routers cache this map and consult it on every request. When partitions split or move, the map is updated and the change propagates so routers stop sending traffic to stale owners. This is the component that turns a key into these three specific nodes.
A partition is the unit of data ownership, scaling, and replication. It owns a slice of the ring and is copied to a small replica group (typically three) placed in different availability zones. The partition is what splits when data or traffic grows, and the replica group is what keeps it available and durable when hardware fails.
The machine that physically stores item data on SSD. It runs a local storage engine, commonly a log-structured merge tree, that buffers writes in memory, appends them to a log, and flushes sorted runs to disk that are later compacted. This gives high write throughput and fast indexed point and range reads within a partition.
The mechanism that keeps replicas consistent. Production DynamoDB uses a per-partition leader that sequences writes, appends them to a write-ahead log, and replicates to peers, acknowledging once a durable quorum accepts. The original Dynamo was leaderless and used sloppy quorums with N, W, and R tunables. Either way, the write and read paths only need a majority of the replica group to make progress, so one slow or dead replica does not block the operation.
A subsystem that maintains global and local secondary indexes as separate partitioned tables. It consumes the base table ordered change stream and applies each mutation to the relevant index partition. Because this happens asynchronously for a GSI, the index is eventually consistent and has its own throughput and its own partition key.
The multi-tenant guardrail. Every table (and effectively every partition) has an allowed request rate, either provisioned or on-demand. When traffic exceeds what a partition can serve, requests are throttled with a retriable error, and a token-bucket style mechanism lets short bursts through while smoothing sustained overload. This is what keeps one hot key or noisy tenant from starving everyone sharing the fleet.
The service that knows which nodes are alive and which own what. In the Dynamo paper this is gossip-based, with nodes exchanging membership and partition information peer to peer. In production DynamoDB it is backed by a more centralized, consensus-backed control service. Its output feeds the metadata map and triggers replacement of failed replicas.
The control-plane logic that watches partition size and traffic and decides to split a partition (when it grows past a size or throughput threshold) or to move a partition to a less loaded node. It performs this online: it copies the data to new owners, catches up from the log, then atomically flips ownership in the metadata map so clients never see downtime.
base item table. The primary store. The partition key decides which partition and replica set an item lives on; the optional sort key orders items that share a partition key so you can…
Every table for DynamoDB (a distributed key-value store), its keys, and which store fits it and why.
Consistent hashing and virtual nodes. The core problem in a key-value store is deciding which machine owns which key, in a way that stays balanced and does not reshuffle everything when you add or remove a…
9 deep dives on the parts that break at scale: Consistent hashing and virtual nodes; Partitioning, hot partitions, and adaptive capacity; Replication and quorums (N, W, R) with eventual versus strong reads.
Leaderless quorum (original Dynamo) versus single-leader per partition (production DynamoDB). A fully leaderless design with sloppy quorums maximizes write availability during partitions, since any healthy replica can accept a write, but it produces concurrent…
6 decisions an interviewer expects you to defend, each with the alternative and why it loses here.
One item, such as a global counter, gets more writes per second than a single partition can take. Adaptive capacity is already on. What do you do?
4 follow-up questions with model answers, the interview scorecard for this question, and a mock interview on Design DynamoDB (a distributed key-value store) with the AI tutor.
The design above tracks two authoritative public sources that bookend the system history. The 2007 SOSP paper Dynamo: Amazon's Highly Available Key-value Store by DeCandia and colleagues introduced the ideas that everything else builds on: consistent hashing with virtual nodes, N/W/R quorums, sloppy quorums with hinted handoff for availability during partitions, vector clocks with application-side reconciliation, gossip-based membership, and an explicit choice of availability over strong consistency for the shopping-cart use case. That paper directly inspired Cassandra, Riak, and Voldemort. Fifteen years later, the 2022 USENIX ATC paper Amazon DynamoDB: A Scalable, Predictably Performant, and Fully Managed NoSQL Database Service documents how the production service diverged from the paper: it emphasizes predictable performance and admission control, describes moving away from pure leaderless replication toward leader-based partitions with a write-ahead log, and explains adaptive capacity and how the service isolates hot partitions and noisy tenants. An honest interview answer distinguishes the two: the paper is the conceptual foundation, but production DynamoDB made deliberate changes (a per-partition leader, managed repartitioning, admission control) precisely because the fully leaderless model pushed too much complexity onto developers. Any claim that DynamoDB is strongly consistent by default, or that a good partition key does not matter, contradicts these sources.
If any of these topics are fuzzy, the interviewer will catch it. Each lesson is 15 to 60 minutes with diagrams, code, and a quiz.
Design a Key-Value Store
capstone / capstone
Quorum
advanced / distributed systems core
Vector Clocks
advanced / distributed systems core
CAP Theorem
advanced / distributed systems core
Hash Partitioning
foundation / database fundamentals
Database Sharding
foundation / database fundamentals
SQL vs NoSQL
foundation / core fundamentals
interview readiness
Three questions from this guide. Answer them without scrolling up, the way you would have to in the room.
India: UPI, cards or netbanking through Razorpay. Elsewhere: card or PayPal. Download at once from My packs.
Free PDF · 79 pages
25 real tech interview questions, answered in full
Five from each of our AI, GenAI, Inference, Maths for ML and Forward Deployed packs. Each with a diagram and a model answer. Free by email.
It is really nice and good Please join the course