AlgoViz

Dynamo: Amazon's highly available key-value store

medium 35 min

Amazon's shopping cart had to accept every add, even while servers and links failed.

Theory

Read or listen first. About 4 min.

What it is

Dynamo is a key-value store that Amazon built for services that only read and write by primary key, such as shopping carts, session state, best seller lists and the product catalog (§1). It offers two calls: get(key) and put(key, context, object) (§4.1). It was described in the paper "Dynamo: Amazon's Highly Available Key-value Store" by DeCandia, Hastorun, Jampani, Kakulapati, Lakshman, Pilchin, Sivasubramanian, Vosshall and Vogels, presented at SOSP 2007, the ACM Symposium on Operating Systems Principles, held 14 to 17 October 2007 in Stevenson, Washington.

The paper's own words for its goal are an "always writeable" data store (§2.3). To get there it gives up strong consistency during some failures. When copies disagree, Dynamo keeps every version it cannot order and hands them to the application to merge.

The paper does not invent one big new algorithm. Its main contribution, in its own words, is showing how known techniques can be combined into one highly available system that works in production (§1). Table 1 of the paper lists them: consistent hashing, vector clocks, sloppy quorums with hinted handoff, Merkle trees and gossip. This page teaches each one and how they fit together.

Level: must-know (three stars) in our papers list. Read it: about 16 pages. Before it: consistent hashing and Lamport clocks help, and both are explained here as far as Dynamo needs them.

Why it exists

Amazon ran its shop on tens of thousands of servers in many data centres. At that size something is always broken: the paper calls failure handling "our standard mode of operation" (§1). A customer still had to be able to add an item to the cart while disks failed and network routes flapped.

Classic replicated databases keep copies strongly consistent by coordinating them during the write. When they cannot be sure, they refuse the write (§2.3). For a cart that means a lost sale. Dynamo flips the choice: never refuse a write, and do the hard work of resolving conflicts when the data is read.

The paper also changed how people talk about storage. Werner Vogels wrote in 2017 that it served as a catalyst for the category now called NoSQL. In interviews today its ideas, more than the paper itself, are what you are expected to use: quorums, vector clocks, consistent hashing and hinted handoff.

A short history

  1. 1978

    Leslie Lamport publishes "Time, clocks, and the ordering of events in a distributed system" in Communications of the ACM 21(7). Dynamo's vector clocks cite it as their root (reference 12 of the paper).

  2. 1997

    Karger and others present consistent hashing at STOC '97, 4 to 6 May, El Paso. Dynamo's partitioning is built on it (reference 10).

  3. 2004

    Amazon runs Oracle's enterprise edition with clustering and replication and cannot meet its availability and scale needs, Vogels wrote in 2017. A 2012 post by Vogels traces several outages in the 2004 holiday season to commercial technology pushed beyond its limits.

  4. 2007

    On 2 October Vogels posts the paper on All Things Distributed. It is presented at SOSP, 14 to 17 October, in Stevenson, Washington.

  5. 2012

    Amazon launches DynamoDB on 18 January. Vogels' launch post says it is based on the principles of Dynamo and combines them with the best parts of SimpleDB.

  6. 2022

    The DynamoDB paper at USENIX ATC, 11 to 13 July, says DynamoDB shared most of Dynamo's name but little of its architecture: each partition has a leader chosen with Multi-Paxos.

Words to know

Consistent hashing
Put machines and keys on one circle of hash values. A key belongs to the first machine clockwise from it. Adding a machine moves only nearby keys.
Virtual node or token
One position of a machine on the ring. Each machine has several, which spreads its load round the circle.
Preference list
The machines responsible for a key, in ring order, distinct machines only. The first N are the owners, the rest are spares (§4.3).
N, R, W
N copies of each key. A read waits for R answers, a write waits for W acknowledgements, the coordinator included (§4.5).
Coordinator
The node that handles one get or put, usually the first owner in the preference list (§4.5).
Vector clock
A list of (node, counter) pairs on each version. It tells whether one version has seen another, or whether they happened side by side (§4.4).
Sibling
One of several versions that no clock orders. A get returns all of them and the application merges them.
Sloppy quorum
Reads and writes go to the first N healthy nodes in the preference list, which may not be the N owners (§4.6).
Hinted handoff
A stand-in node keeps a copy with a note naming the real owner, and hands it back when the owner returns (§4.6).
Anti-entropy and Merkle tree
A background job that finds differences between replicas by comparing a tree of hashes from the top down (§4.7).
Gossip
Every second each node talks to one random peer and they merge what they know about membership (§4.8.1).
Read repair
After a read, the coordinator sends the newest version to replicas that answered with an old one (§5).

How it works

Step through the idea, or press Play.

Step 1 of 4

Place. Hash the key onto the ring, walk to N distinct machines

Understand it

Start here

The paper on one card

PaperDynamo: Amazon's Highly Available Key-value Store
AuthorsG. DeCandia, D. Hastorun, M. Jampani, G. Kakulapati, A. Lakshman, A. Pilchin, S. Sivasubramanian, P. Vosshall, W. Vogels (Amazon.com)
Venue and yearSOSP 2007, 21st ACM Symposium on Operating Systems Principles, 14 to 17 October 2007, Stevenson, Washington
DOI10.1145/1294261.1294281
Read it[PDF on All Things Distributed](https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf), or the [Amazon Science page](https://www.amazon.science/publications/dynamo-amazons-highly-available-key-value-store)
LevelMust-know. About 35 minutes here, 16 pages in the original
Helps to know firstConsistent hashing and the idea of logical clocks
Section numbers on this page, written §4.6 and so on, point into the PDF, so you can check every claim.

The analogy

The street party list

Five neighbours, Asha, Lee, Noor, Sam and Max, live in cottages on a path round a pond. Together they keep the shopping list for a street party. There is no single master copy. Each line of the list is kept in three cottages, and anyone may add a line at any hour, even when a neighbour is away or the path is blocked.

Keeping one list in five cottages
AshaLeeNoorSamMaxStreet partylemonadecrispsAdd cups!The list that never says no

Nobody ever refuses a new line. The cost is that pages can disagree for a while, and someone has to merge them.

Section 1 and 2

The problem before the paper

Before Dynamo, the usual answer for state was a relational database. The paper gives three reasons it did not fit these services (§2). Most of them only read and write by primary key, so the rich query features cost money for nothing. The replication technology of the day usually chose consistency over availability. And it was hard to scale out and spread load across many machines.

A strongly consistent design must answer one awkward question during a failure: what if I cannot be sure my copy is the latest? Its answer is to wait or refuse. The paper puts it plainly: the data is made unavailable until it is absolutely certain that it is correct (§2.3).

The old answer: refuse while unsure

Our own simple example of a single-primary design during failover. The write is refused because no copy can promise it is the latest.

What the services needed (§2.1, §2.3)

  • Simple queries

    Read and write one item by key. No operation spans several items, and objects are usually smaller than 1 MB.

  • Always writeable

    Rejecting a customer's update gives a poor experience, so writes must be accepted even during failures.

  • Tight tail latency

    Service level agreements are measured at the 99.9th percentile, not the average.

  • Trusted, small clusters

    Internal use only, no hostile nodes, and each service runs its own instance of up to hundreds of hosts.

The paper also states four principles (§2.3). Incremental scalability: add one machine at a time. Symmetry: every node has the same job. Decentralization: prefer peer-to-peer techniques, because central control had caused outages. Heterogeneity: a bigger machine should be able to take more work.

Why the 99.9th percentile matters

P(one page avoids every slow call)=0.999150≈0.86P(\text{one page avoids every slow call}) = 0.999^{150} \approx 0.86
The paper says one page can call more than 150 services (§2.2). If each call independently had a 1 in 1,000 chance of being slow, about 14% of pages would hit at least one. The independence and the 1 in 1,000 are our assumptions, chosen to show why Amazon measured the tail.

The key idea

The whole paper in one picture

One put: three copies, two acknowledgements

A shopper adds a pen. The cart service sends put of cart:42 with its context to node A, the coordinator, in data centre 1. A stamps clock A:2 and sends the version to node B in data centre 1 and node C in data centre 2. B acknowledges, so two copies exist, and A replies OK to the cart service. C's acknowledgement arrives later and nobody waits for it.
Placement by the ring, durability by N, latency by W and R, conflicts by vector clocks. Copies are spread across data centres (§4.6).

Table 1 of the paper, in our words

ProblemTechniqueWhat it buys
PartitioningConsistent hashingAdd machines one at a time
Always writeableVector clocks, reconciled during readsAccept writes, sort out conflicts later
Short failuresSloppy quorum and hinted handoffKeep writing when some replicas are away
Long failuresAnti-entropy with Merkle treesReplicas catch up in the background
Membership and failure detectionGossipNo central registry to fail
The paper's Table 1 is the best map of the paper. Keep it open while you read §4.

Step 1

Spread the keys on a ring

Dynamo hashes each key with MD5 into a 128-bit number (§4.1). Picture the numbers bent into a circle, so the largest wraps round to the smallest. Each machine sits at some positions on the circle. A key belongs to the first machine you meet walking clockwise from the key (§4.2).

Plain consistent hashing gives each machine one random spot, which leaves some arcs much bigger than others and ignores that machines differ in size. Dynamo gives each machine several positions, called virtual nodes or tokens. When a machine leaves, its load spreads across many others. When one joins, it takes a little from many. A bigger machine can get more tokens (§4.2).

How much moves when a machine joins

keys moved≈KS+1with hash mod S: about K(1−1S+1)\text{keys moved} \approx \frac{K}{S+1} \qquad \text{with } \texttt{hash mod } S:\ \text{about } K\left(1 - \frac{1}{S+1}\right)
K keys on S machines, ideal spread. With a ring, the new machine takes its fair share and nothing else moves. With hash mod S almost every key changes machine. For S = 4: about 20% versus about 80%.

Step 2

Copy each key to N machines

The first machine clockwise is the key's coordinator. It also copies the key to the next N - 1 machines clockwise (§4.3). In Figure 2 of the paper, B stores keys in the range from A to B and copies them to C and D. So each machine is responsible for the arc between itself and its Nth predecessor.

The list of machines responsible for a key is its preference list. Two details matter. First, with tokens the next three positions may belong to only two machines, so the walk skips positions of machines already in the list. Second, the list holds more than N machines, so there are spares when one fails (§4.3). Section 4.6 adds that the list is built so the machines span several data centres.

Building the list for cart:42 on our toy ring

WalkTokenMachineDecisionList so far
110Anew machineA
222Bnew machineA, B
330Askip: A is already inA, B
440Cnew machine, N = 3 reachedA, B, C
555DspareA, B, C, then D
Our own example: a ring of 100 positions, tokens A 10 and 30, B 22 and 70, C 40 and 85, D 55 and 95. cart:42 hashes to 5.

Step 3

Count to W, count to R

Any node can receive a request. If it is not among the key's top N, it forwards the request to the first of them (§4.5). The coordinator then does this. For a put, it gives the new version a vector clock, writes it locally, sends it to the N highest-ranked reachable nodes, and answers success once W - 1 of them reply, because its own copy counts as one. For a get, it asks the same nodes for every version they hold, waits for R answers, and returns every version that is not an ancestor of another (§4.5).

A put and a get with N = 3, R = 2, W = 2

Latency is set by the slowest of the W or R nodes you wait for, not the slowest of all N. That is why R and W are usually below N (§4.5).

When do a read and a write meet?

R+W>N  ⇒  ∣read set∩write set∣≥R+W−N≥1R + W > N \;\Rightarrow\; |\text{read set} \cap \text{write set}| \ge R + W - N \ge 1
If both sets are drawn from the same N nodes, they must share at least one. With (3, 2, 2): 2 + 2 - 3 = 1 shared node. The paper calls this quorum-like (§4.5). Step 5 shows when the same N is not used.

Settings the paper reports (§6)

UseN, R, WWhat it means
Common setting3, 2, 2Reads and writes overlap without failures; one slow node does not slow anyone
High performance read engineR = 1, W = NProduct catalog and promotions: many reads, few updates
Highest write availabilityW = 1A write succeeds while any single node can store it, but it may live on one machine for a while
Typical N3N sets durability
Low W and R raise the risk of reading something old and open a window in which a write lives on few machines (§6).

What W buys, in our own numbers

P(write OK)=∑k=WN(Nk)pk(1−p)N−kN=3, p=0.99: W=1→0.999999, W=2→0.9997, W=3→0.970P(\text{write OK}) = \sum_{k=W}^{N} \binom{N}{k} p^k (1-p)^{N-k} \qquad N{=}3,\ p{=}0.99:\ W{=}1 \to 0.999999,\ W{=}2 \to 0.9997,\ W{=}3 \to 0.970
p is the chance that one owner is reachable, assumed independent. This ignores the sloppy quorum, which makes real writes even more available. It shows the trade the paper describes: a higher W protects durability and costs availability (§6).

Step 4

Version every change with a vector clock

Dynamo treats each change as a new, immutable version (§4.4). Usually a new version simply replaces the old one and the system can tell by itself. That is syntactic reconciliation. During failures plus concurrent updates, the history can branch. Then the system cannot pick, so the client must merge the branches. That is semantic reconciliation.

To tell the two cases apart, every version carries a vector clock, a list of (node, counter) pairs. Version a is an ancestor of version b if every counter in a is less than or equal to the matching counter in b. Otherwise they conflict (§4.4). A client that updates must pass the context from its earlier read, which holds the clock of what it saw.

Figure 3 of the paper, step by step

VersionWritten byClockRelation
D1Sx[(Sx, 1)]first version
D2Sx[(Sx, 2)]descends from D1, which can be dropped
D3Sy[(Sx, 2), (Sy, 1)]descends from D2
D4Sz, after a client read D2[(Sx, 2), (Sz, 1)]descends from D2, concurrent with D3
D5Sx, after a client read D3 and D4 and merged them[(Sx, 3), (Sy, 1), (Sz, 1)]covers both branches
Sx, Sy and Sz are the paper's names for three nodes. A read that found D3 and D4 returns both, with the summary clock [(Sx, 2), (Sy, 1), (Sz, 1)] as context.

Compare two clocks

A missing node counts as 0. Only the last box needs the application.
Python
def descends(a, b):    """True if clock a has seen everything clock b has seen."""    return all(a.get(node, 0) >= n for node, n in b.items())def relation(a, b):    if descends(a, b) and descends(b, a): return "same"    if descends(b, a): return "a is older"    if descends(a, b): return "b is older"    return "concurrent: keep both"d2 = {"Sx": 2}d3 = {"Sx": 2, "Sy": 1}d4 = {"Sx": 2, "Sz": 1}d5 = {"Sx": 3, "Sy": 1, "Sz": 1}print("D2 vs D3:", relation(d2, d3))print("D3 vs D4:", relation(d3, d4))print("D5 vs D4:", relation(d5, d4))
The clocks of Figure 3. The full store is in the Code tab.
Edit and run it in your browser

Clocks can grow if many nodes coordinate writes to one object. In practice writes are usually handled by one of the top N nodes, so clocks stay short. To be safe, Dynamo stores a timestamp with each pair, and when a clock reaches a threshold, the paper says "say 10" pairs, it drops the oldest pair. That can make an ancestor look concurrent, but the paper reports the problem had not shown up in production (§4.4). The general topic of versions is covered in data versioning.

Step 5

Keep writing when a node is down

A strict quorum would wait for the N owners. If one is down or cut off, the write fails. Dynamo uses a sloppy quorum instead: every read and write goes to the first N healthy nodes in the preference list, which may not be the first N on the ring (§4.6).

In the paper's example, with N = 3, if node A is down, a replica meant for A goes to D. It carries a hint naming A. D keeps hinted replicas in a separate local database and scans it now and then. When A is back, D delivers the replica and may delete its own copy, so the number of replicas does not drop (§4.6).

Hinted handoff

The write counted two acknowledgements, A's own and B's, so it succeeded while an owner was away.

Whole data centres can fail too: power, cooling, network or natural disasters. Dynamo builds each preference list across several data centres connected by fast links, so a whole data centre can go without a data outage (§4.6). A different view on what to give up during a split: the CAP theorem.

Step 6

Repair what the hints missed

Hints work best when failures are short and membership barely changes. A stand-in can itself fail before it hands a replica back. For that and other threats, Dynamo runs anti-entropy: replicas compare their data in the background and copy what is missing (§4.7).

Comparing every key would be slow. So each node keeps a Merkle tree for each key range it holds. A leaf is the hash of one key's value, and each parent is the hash of its children. If two roots are equal, the whole range is equal. If not, the nodes compare the children and keep going down only where hashes differ, until they find the keys that are out of sync (§4.7).

Two replicas look for a difference

One difference among many keys costs a handful of hash comparisons, not a full scan.

Cost of finding one bad key

comparisons≈2log⁡2L+1L=1,048,576 leaves⇒≈41\text{comparisons} \approx 2 \log_2 L + 1 \qquad L = 1{,}048{,}576 \text{ leaves} \Rightarrow \approx 41
Our own figure for a binary tree with one leaf per key and one differing key: at each level you compare two children. Real trees put many keys under a leaf. Either way you send a few dozen hashes instead of a million values.

Three ways copies find each other again

Inside one Dynamo instance, node A writes a version that node C could not take to node D, which keeps it in its hinted store with the note for C. When C returns, D hands the copy back. Node B compares Merkle tree hashes with C and copies only the range that differs. A gossips to B that C is back.
Hints for short failures, Merkle trees for what hints miss, gossip so everyone knows who is up and where tokens are.

The drawback in the original scheme: when a node joins or leaves, many key ranges change and their trees must be rebuilt. The fixed partitions of §6.2 solve that, as the numbers part shows.

Step 7

Gossip about who is in the ring

Nodes are added and removed explicitly: an operator uses a command line tool or a browser to tell a node about the change, which is written to persistent storage (§4.8.1). The paper's reason is that an outage rarely means a node left for good, so it should not trigger rebalancing.

Then gossip spreads it. Every second, each node contacts one random peer and they reconcile their histories of membership changes. The same exchange spreads which tokens each node owns, so every node can send a request straight to the right nodes. That is why the paper calls Dynamo a zero-hop distributed hash table (§3.3, §4.8.1).

One gossip exchange

News reaches all nodes after a few rounds, with no central registry.

Two more pieces. Seeds are nodes everyone knows through configuration, so two halves of a ring that were started separately still find each other (§4.8.2). And failure detection is local: A treats B as failed if B does not answer A, even if B answers C. A then uses other nodes and retries B now and then (§4.8.3). Early designs kept a global view of failures, but explicit join and leave made it unnecessary. More on detectors in general: failure detection.

Step 8

One request, one state machine

Each node has three parts, all in Java: request coordination, membership and failure detection, and a pluggable local storage engine. Most instances used the Berkeley DB Transactional Data Store; others used BDB Java Edition, MySQL, or an in-memory buffer with a persistent store behind it (§5). Every client request gets its own state machine on the node that received it.

The read state machine of §5

Read repair happens after the reply, so it does not slow the client down (§5).

One more trick targets the tail. Letting only the first node coordinate writes put too much load on some nodes, so any of the top N may coordinate. Because a write usually follows a read, the coordinator is the node that answered that read fastest, which the context records. That raises the chance of read-your-writes and makes latency steadier (§5).

Section 6

The numbers that matter

NumberValueWhereWhat it means for a design
Common (N, R, W)(3, 2, 2)§6The default to quote in an interview
Example SLA300 ms for 99.9% of requests at a peak of 500 requests per second§2.2Set targets on the tail, not the mean
Tail versus average99.9th percentile around 200 ms, an order of magnitude above the average§6.1, Figure 4Averages hide what slow users see
Write bufferA buffer of 1,000 objects cut the 99.9th percentile by a factor of 5 at peak§6.1, Figure 5Trades durability for speed; one replica still does a durable write
One version per read99.94% of cart requests in 24 hours§6.3Conflicts are rare; most came from many concurrent writers, often robots
Successful responses99.9995% without timing out, no data loss event§6.6Over the two years the paper covers
Client-driven routing99.9th percentile reads 30.4 ms versus 68.9 ms server-driven§6.4, Table 2Skipping the load balancer hop helps the tail most
Clock size threshold"say 10" pairs§4.4Truncation keeps clocks small
Gossip and pollingEvery 1 s between nodes; clients poll every 10 s§4.8.1, §6.4Membership can be up to 10 s stale at a client
Busy dayTens of millions of requests, well over 3 million checkouts in one day§1The cart service on Dynamo, holiday season
All values as printed in the paper. In §6.3 the shares for 2, 3 and 4 versions are 0.00057%, 0.00047% and 0.00009%; as printed they do not add up to exactly 100% with 99.94%.

Load balancing efficiency (§6.2)

efficiency=average requests per noderequests at the hottest node\text{efficiency} = \frac{\text{average requests per node}}{\text{requests at the hottest node}}
1 means perfectly even. The paper compares three partitioning strategies with this measure for 30 nodes and N = 3, at equal amounts of membership data per node (Figure 8).

How partitioning changed in production (§6.2)

StrategyHowProblem or gain
1: random tokens, partition by tokenT random tokens per node; ranges between tokensA join scanned other nodes' stores; bootstrapping took almost a day at busy times; Merkle trees rebuilt; archiving hard
2: random tokens, equal partitionsQ equal ranges, tokens only decide placementWorst balance; used briefly while migrating
3: Q / S tokens, equal partitionsQ equal ranges; each of S nodes holds Q / S of themBest balance; membership data three orders of magnitude smaller than strategy 1; partitions move as files
The lesson: keep partitioning (where the cuts are) separate from placement (who holds each piece). The price of strategy 3 is coordination when membership changes.

Smaller lessons from §6

  • Imbalance falls with load

    Out-of-balance nodes were about 20% at low load and close to 10% at high load, using a 15% threshold. More popular keys spread better.

  • Background work waits

    Repair and handoff tasks get time slices from an admission controller that watches foreground latency, for example the 99th percentile of database reads over 60 seconds.

  • Three ways to merge

    Business logic (the cart), last write wins by timestamp (session state), or a read engine with R = 1 and W = N (catalog).

  • Limits of full membership

    Each node gossips the full routing table. Fine for a couple of hundred nodes, hard for tens of thousands (§6.6).

Since 2007

What aged badly, and what changed

How the field moved

  • Apache Cassandra took the ring, tokens, gossip, hints and Merkle repair, but resolves conflicts with last write wins on per-column timestamps instead of vector clocks.
  • Riak, another Dynamo-style store, returns siblings and recommends dotted version vectors over plain vector clocks to limit siblings.
  • Amazon DynamoDB (2012) is a managed service with a leader per partition, chosen with Multi-Paxos, and offers strongly consistent reads.
  • Data types with built-in merge rules, such as sets that track adds and removes, are a principled answer to the cart problem.

Did not age well

  • Asking every application to merge versions is hard work. Even the paper says some developers pushed it back to the store, which then used last write wins (§2.3).
  • A union merge brings back deleted items, as §4.4 admits. You need remove markers or a smarter data type.
  • Each team ran its own instance. The DynamoDB paper says that operational load became a barrier to adoption.
  • Sloppy quorums make R + W > N a weak promise during failures, which is often misquoted.

Dynamo is not DynamoDB

Dynamo (2007 paper)DynamoDB (2022 paper)
Who runs itEach service team ran its own instanceA managed AWS service
ReplicationLeaderless: any of the top N coordinatesOne leader per partition, elected with Multi-Paxos
Write done whenW replicas, sloppy quorumA quorum of the replication group has the log record; two of three replicas in different zones
ReadsEventually consistent; siblings possibleStrongly consistent reads from the leader, or eventually consistent from any replica
ConflictsVector clocks, application mergesOne leader orders writes per partition
From the DynamoDB paper, USENIX ATC 2022, sections 2, 3 and 6.1: it "shared most of the name" of Dynamo "but little of its architecture". See DynamoDB and a recent DynamoDB outage.

Connections

Where Dynamo sits

Lineage

Bayou, Coda and Ficus are named in §3.2 as systems that allow disconnected work and resolve conflicts later. Avinash Lakshman, a Dynamo author, is also an author of the Cassandra paper.

Do not mix these up

SystemWho decides orderConsistency during a splitData model
DynamoNobody: vector clocks and the appAccepts writes, may return siblingsKey to opaque blob
BigtableA single master assigns tablets; one server per tabletA row is served by one tablet serverSorted rows, column families, timestamps
CassandraTimestamps per cell, last write winsTunable per request: ONE, QUORUM, ALLRows and columns in partitions
DynamoDBA leader per partition (Multi-Paxos)Strong reads need the leaderItems with a partition key, optional sort key
The Dynamo paper contrasts itself with Bigtable in §3.2: Dynamo targets key-value access where updates are not rejected even during partitions.

Say it aloud

The 60-second recap

  1. 1

    The need

    Amazon needed a store whose writes are never refused, because a lost add to cart is a lost sale.

  2. 2

    Placement

    Keys sit on a consistent-hash ring with several tokens per machine. Each key has N copies on distinct machines.

  3. 3

    Counting

    A write succeeds after W acknowledgements, a read waits for R answers. Services tune them; 3, 2, 2 was common.

  4. 4

    Versions

    Concurrent writes create versions tracked by vector clocks. The application merges the ones the clocks cannot order.

  5. 5

    Repair

    Short failures use a sloppy quorum and hinted handoff. Merkle trees fix lasting drift. Gossip spreads membership.

  6. 6

    The price

    Eventual consistency: a read can be stale, merges are your code, and a removed item can come back.

The original

Read it in three passes

S. Keshav's "How to Read a Paper" suggests three passes: a quick look, a careful read of the figures, and a pass in which you could almost rebuild the work. Here is that plan for Dynamo.

  1. 1

    Pass 1, about 10 minutes

    Read the abstract, §1, §2.3 on design choices, the headings of §4, Table 1, and §7. Then fill in the five Cs below before you look at our answers.

  2. 2

    Pass 2, about 45 minutes

    Read §4.1 to §4.9 with the Visualize tab open. Study Figure 2 (the ring), Figure 3 (clocks), Figures 4 and 5 (latency), and Figures 7 and 8 (partitioning). Skim §3, related work.

  3. 3

    Pass 3, about an hour

    Run the Code tab. Set N = 3, R = 2, W = 2, take one node down, write from both sides of a split, and predict the siblings before you print them. Then list the paper's hidden assumptions.

  4. 4

    Skip for interviews

    The storage engine plug-ins of §5 and the details of the admission controller in §6.5. Know that they exist, not how they work.

The five Cs for this paper

COur answer
CategoryA description of a production system, with measurements
ContextConsistent hashing, Lamport's logical clocks, quorum systems, and systems that reconcile later such as Bayou and Coda
CorrectnessAssumes trusted nodes, small objects, single-key operations, and applications willing to merge
ContributionsShowing that these techniques combine into one always-writeable store that meets tail-latency targets in production
ClarityClear and practical; Table 1 is the map, and some numbers are given only as aggregates to protect business details (§1)

Summary

The whole topic in one minute.

Dynamo is Amazon's 2007 answer to one question: how do you keep a store writable while machines and links fail? Keys sit on a consistent-hash ring with several tokens per machine. Each key has N copies on the first N distinct machines clockwise. A write is done after W acknowledgements and a read after R answers, and each service picks its own numbers, usually 3, 2 and 2.

Concurrent writes create versions that vector clocks cannot order. Dynamo keeps them all and the application merges them, which never loses an add but can bring back a removed item. A down node's writes go to a stand-in with a hint, Merkle trees repair what hints miss, and gossip spreads membership with no central coordinator. The price is eventual consistency: a read can be stale and merging is your code.

  • Dynamo, SOSP 2007: an always-writeable key-value store for Amazon's cart and similar services.
  • Consistent hashing with several tokens per machine; a preference list of N distinct machines, plus spares.
  • A put is done after W copies, a get after R answers; (3, 2, 2) was common, and R + W > N overlaps only when the same N answer.
  • Vector clocks tell newer from concurrent; siblings go to the application, which merges them.
  • A union merge never loses an add but can bring back a removed item.
  • Sloppy quorum and hinted handoff for short failures, Merkle trees for long ones, gossip for membership.
  • SLAs at the 99.9th percentile; 99.94% of cart reads saw one version.
  • DynamoDB shares the name, not the design: it uses a leader per partition chosen with Multi-Paxos.

Sources