iTranslated by AI
Design Anatomy of a Highly Available Key-Value Store: Lessons from Amazon's Dynamo
Introduction
For e-commerce providers like Amazon, even a brief service outage can lead to significant financial consequences. In an infrastructure consisting of tens of thousands of servers and network components, component failures, whether large or small, occur daily. Under these conditions, state management determines the reliability of the system.
While traditional databases provide many features, high availability and horizontal scalability require complex solutions. On the other hand, many web services, such as shopping carts and session management, often find simple key-value access patterns to be sufficient.
Dynamo, developed by Amazon, provides a simple key-value interface while achieving "always-on" high availability, sacrificing consistency in specific failure scenarios.
Based on "Dynamo: Amazon’s Highly Available Key-value Store," I will note Dynamo's design principles and architecture here.
This paper, presented at SOSP (ACM Symposium on Operating Systems Principles) in 2007, provides a detailed explanation of Dynamo's design principles and architecture. Although it is an older paper, Dynamo is used by many Amazon services, and its design principles remain valid today.
Overview of the Dynamo System
Dynamo is a platform that combines multiple distributed systems technologies to achieve high availability. The following table summarizes Dynamo's key technical elements.
| Problem | Adopted Technique | Advantage |
|---|---|---|
| Data Partitioning | Consistent Hashing | ・Incremental scalability ・Minimal redistribution during node addition/removal |
| High Availability for Writes | Vector clocks with reconciliation during reads | ・Decoupling of update frequency and version size ・Efficient conflict detection |
| Handling Temporary Failures | Sloppy Quorum and Hinted Handoff | ・Maintains high availability even when some replicas are unavailable |
| Recovery from Permanent Failures | Anti-entropy using Merkle trees | ・Background replica synchronization ・Efficient data comparison |
| Membership and Failure Detection | Gossip-based protocol | ・Maintains symmetry ・Avoids centralized registries |
Dynamo features a fully decentralized architecture where each node has equal responsibility. Consequently, adding or removing nodes can be performed without manual partitioning.
The actual request processing flow looks something like this:
Dynamo is used for various use cases on the Amazon platform.
| Service Type | How Dynamo is Used | Characteristics |
|---|---|---|
| Shopping Cart Service | Application-specific reconciliation logic | ・Merge different versions of the cart ・Always writeable |
| Session Management | Timestamp-based reconciliation | ・"Last write wins" policy ・High availability is critical |
| Product Catalog and Promotions | High-performance read engine | ・High read / low write ・R=1, W=N configuration |
Dynamo supports these services, handling peak loads without downtime even during busy holiday seasons. The shopping cart service processes tens of millions of requests and over 3 million checkouts in a day, while the session management service handles hundreds of thousands of concurrent sessions (as of the time the paper was written).
A major difference from traditional distributed systems is that Dynamo prioritizes availability over consistency in the CAP theorem. While many distributed databases sacrifice availability for consistency, Dynamo uses an "eventual consistency" approach to guarantee that updates eventually reach all replicas.
Basic Design Principles
Trade-off between Availability and Consistency
A fundamental challenge in distributed system design is the balance between availability and consistency. The following table illustrates this trade-off.
| Aspect | Strong Consistency Model | Dynamo's Eventual Consistency Model |
|---|---|---|
| Behavior during Network Partition | ・Reject write operations ・Prioritize consistency at the cost of availability |
・Always accept write operations ・Prioritize availability while tolerating temporary inconsistency |
| Conflict Resolution Timing | Resolved at write time | Resolved at read time |
| Conflict Resolution Responsibility | Storage system | Application |
In Amazon's experience, data stores that fully guarantee ACID attributes tend to have lower availability. Dynamo prioritizes high availability over consistency, does not provide isolation guarantees, and only allows single-key updates.
In services like shopping carts, rejecting customer updates harms the customer experience. Customers must be able to add or remove items from their carts even if there are network or server failures, which necessitates an "always writeable" system.
CAP Theorem in Practice
Distributed systems cannot achieve both strong consistency and high availability simultaneously in environments where network failures are possible. Dynamo accepts this constraint and enhances availability using optimistic replication techniques. Changes are propagated to replicas in the background, and disconnected concurrent work is tolerated. The challenge lies in detecting and resolving conflicting changes, but Dynamo guarantees eventual consistency. That is, all updates eventually reach all replicas.
The "Always Writeable" Philosophy
A fundamental characteristic of Dynamo is its "always writeable" design philosophy.
| Design Aspect | Traditional Approach | Dynamo's Approach | Impact |
|---|---|---|---|
| Conflict Resolution Timing | At write time | At read time | ・Write operations always succeed ・Conflict resolution complexity moves to the read side |
| Conflict Resolution Method | Data store level | Application level | ・Appropriate resolution with understanding of the data schema ・Handling aligned with business logic |
| Version Management | Single version | Parallel management of multiple versions | ・Causal tracking using vector clocks ・Achievement of eventual consistency |
This design reflects Amazon's philosophy of prioritizing the customer experience. It ensures that writes are not rejected by shifting complexity from write operations to read operations.
Incremental Scalability and Decentralization
Dynamo can scale out one node at a time with minimal impact on the system. Capacity can be added incrementally in response to traffic growth.
Furthermore, it emphasizes complete decentralization and symmetry. Each node is equal, and there are no nodes with special roles. This symmetry simplifies system management. By prioritizing decentralized peer-to-peer techniques over centralized control, a simpler and more scalable system is achieved.
Core System Architecture
Data Partitioning via Consistent Hashing
Dynamo's partitioning relies on consistent hashing to distribute load. The output range of a hash function is treated as a circular space (or "ring"), and each node is assigned a position on this ring. Each data item is assigned to the first node found by walking the ring clockwise from the hash value of its key.

https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf
The primary advantage of consistent hashing is that node entry or exit only affects adjacent nodes, but the basic algorithm has some issues:
- Non-uniform distribution due to random assignment of node positions
- Lack of responsiveness to heterogeneity in node performance
To address these, Dynamo introduced the concept of "virtual nodes." Instead of a single point, a single node is assigned to multiple points, allowing each physical node to handle multiple virtual nodes.
Virtual Nodes for Load Balancing
Reiterating the advantages of using virtual nodes, they allow for even distribution of load across nodes.
| Advantage | Description |
|---|---|
| Load balancing during failure | Load from a failed node is evenly distributed among the remaining nodes. |
| Load balancing during recovery | Even load transfer is possible when a new node is added. |
| Handling heterogeneity | The number of virtual nodes can be adjusted based on node capacity. |
This approach improves load balancing and prevents the formation of hot spots. Load redistribution during failures or recovery also becomes more uniform.
Replication Strategy (N-way Replication)
For high availability and durability, Dynamo replicates data across multiple hosts. Each data item is replicated on N hosts, where N is configured per instance. Each key k is assigned to a coordinator node, which stores the key locally for its range and also replicates it to the N-1 subsequent nodes on the ring.
For instance, if N=3, key0 is replicated to s1, s2, and s3.

https://books.dwf.dev/docs/system-design/c7
The list of nodes responsible for storing a specific key is called the "preference list." To prepare for node failures, this list contains N or more nodes.
Quorum-based Consistency (N, R, W Parameters)
To maintain consistency among replicas, two configurable values R and W are used.
- R: The minimum number of nodes required for a read operation
- W: The minimum number of nodes required for a write operation
Setting R + W > N results in a quorum system. This condition ensures that there is an overlap between the sets of nodes for reading and writing, guaranteeing that a read sees the most recent write. Since the latency of get/put operations is determined by the slowest node among the R/W replicas, R and W are usually configured to be smaller than N to improve latency.
Example configurations and their effects are as follows:
| Configuration | Effect | Use Case |
|---|---|---|
| W=1 | ・Operation completes with a single node write ・Highest write availability |
Applications requiring the highest level of availability |
| W=N | ・Write required to all replicas ・Maximum durability |
Applications where data durability is extremely critical |
| R=1 | ・Read possible from any replica ・Highest read availability |
High-performance read engines |
| R=N | ・Acknowledgment required from all replicas ・Highest consistency |
Applications requiring the most up-to-date data |
In production environments, many Amazon services use the setting (N, R, W) = (3, 2, 2). This means the following:
- Data is replicated to 3 servers.
- Reads are obtained from 2 servers.
- Writes are completed if successful on 2 servers.
- Since 2 + 2 > 3, at least one server is guaranteed to participate in both operations.
This allows at least one node containing the latest write to be read, preventing situations where only stale data is retrieved.
Vector Clocks for Version Management
Dynamo provides eventual consistency, where updates propagate asynchronously. Consequently, a get() operation might return an object that does not include the latest update. Some applications on Amazon's platform tolerate this inconsistency. For example, in a shopping cart, an "add" operation must never be rejected.
To achieve this, Dynamo treats each change as a new immutable version of the data. Typically, a new version replaces an old one (syntactic reconciliation), but if conflicting versions arise due to failures or concurrent updates, client-side reconciliation is required (semantic reconciliation).
Vector clocks (a list of (node, counter) pairs) are used to track causal relationships between versions. When a client performs an update, it specifies which version it is updating by including context information.
The specific flow is traced in the diagram below.

https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf
- In the first step, a client writes a new object, and node Sx is responsible for processing this. At this point, object D1 is created and assigned a vector clock [(Sx, 1)].
- Next, the same client updates the object, and node Sx processes it again. A new version D2 is created, and the vector clock is updated to [(Sx, 2)]. D2 logically overwrites D1.
- The same client performs another update, but this time node Sy handles it. As a result, object D3 is created, and the vector clock becomes [(Sx, 2), (Sy, 1)].
- Concurrently, another client reads D2 and updates it, with node Sz taking charge of the processing. This generates object D4, with a vector clock of [(Sx, 2), (Sz, 1)].
- Crucially, since D3 and D4 were created concurrently, neither can logically overwrite the other. Both versions are valid, and the system cannot automatically resolve this conflict.
- Finally, the client receives both versions (D3 and D4) and resolves the conflict at the application level. This reconciled result is written as D5, with node Sx handling the process. The new vector clock becomes [(Sx, 3), (Sy, 1), (Sz, 1)], encompassing the update history of both D3 and D4.
This diagram illustrates key characteristics of Dynamo: "eventual consistency" and "application-assisted conflict resolution." The system tolerates temporary inconsistency and returns multiple versions during a read, allowing the client to ultimately resolve the conflict in a semantically appropriate way.
A problem with vector clocks is that their size grows as many servers coordinate writes. To address this, Dynamo employs a clock truncation scheme that deletes the oldest pair when a threshold (e.g., 10) is reached. While this could theoretically cause issues, it has not manifested in actual operations.
Handling Failure Scenarios
Sloppy Quorum and Hinted Handoff
Dynamo solves the problem where traditional quorum approaches become unavailable during server failures or network partitions through "Sloppy Quorum." Read and write operations are performed on the first N healthy nodes from the preference list, which are not necessarily the first N nodes in the ring.

https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf
For example, under the condition N=3, if node A goes down temporarily, a replica that would normally be stored on A is sent to node D (since B and C in the preference list already have replicas, another destination must be found to replace A). This replica includes a "hint" in its metadata indicating the intended recipient (A). Once A recovers, D transfers the replica back to A.
This prevents operation failures even during temporary outages. High-availability applications can set W=1, allowing a write to succeed if a single node completes it. However, in production environments, many services set a higher W to improve durability.
Furthermore, to handle entire data center failures, Dynamo configures replication across multiple data centers. By replicating between data centers connected via high-speed networks, the system is protected even against total data center outages.
Anti-Entropy using Merkle Trees
While hinted handoff is effective in environments with low churn, there are cases where a hinted replica cannot be returned to its original node. To address such threats to durability, Dynamo implements an anti-entropy protocol.
Dynamo uses Merkle trees (hash trees) to quickly detect inconsistencies between replicas and minimize the amount of data transferred. If the root hashes match, the data is synchronized. If they differ, child hashes are exchanged, continuing until leaves are reached to identify the specific "out-of-sync" keys.
In Dynamo, each node maintains a separate Merkle tree for each key range it hosts. Nodes exchange tree roots for the key ranges they co-host, detect differences, and perform synchronization actions. A drawback is that the trees must be recalculated when a node joins or leaves the system, though this is addressed by an improved partitioning scheme.
Gossip-based Failure Detection and Membership Protocol
In Amazon's environment, node outages (due to failure or maintenance) are often temporary. They rarely signify permanent departure and should not trigger partition rebalancing or repair. Therefore, an explicit membership change mechanism is used.
Administrators connect to a Dynamo node via command line or a browser to issue membership changes. The processing node records the change and a timestamp in a persistent store. A gossip-based protocol propagates this change, where each node contacts a random peer every second to reconcile membership histories.
Upon initial startup, a node selects a set of tokens and saves the mapping to disk. This mapping is synchronized alongside membership change reconciliations, allowing each node to become aware of the token ranges assigned to other nodes.
Recovery Mechanisms
Dynamo includes recovery functions for various failure scenarios. For recovery from temporary failures, nodes restore data from persistent state and apply hinted handoff replicas as needed. For long-term failures, they synchronize with other replicas using the anti-entropy protocol.
There are also recovery mechanisms for node addition and removal, enabling efficient and reliable state transfers.
Request Handling
Flow of Read and Write Operations
There are two ways for a client to select a node:
- Routing requests via a load balancer.
- Routing directly to the coordinator using a partition-aware client library.
The former has the advantage of requiring no Dynamo-specific code, while the latter provides the advantage of reducing latency.
A coordinator (typically the top-ranking node in the preference list) handles the operation. Read and write operations use only healthy nodes; if a node fails, lower-ranked nodes in the preference list are accessed.
Basic Flow of Read Operations
- Send requests to the top N nodes.
- Wait for a minimum of R responses.
- Fail on timeout or collect all versions.
- Perform syntactic reconciliation and generate context as needed.
- Automatically trigger read repair if stale versions are detected.
Basic Flow of Write Operations
- Generate a vector clock and perform a local write.
- Send the update to N reachable nodes.
- Succeed upon receiving responses from at least W-1 nodes.
To optimize performance, the node that responded fastest in the previous read is selected as the write coordinator. This improves "read-your-writes" consistency and enhances 99.9th percentile performance.
Conflict Detection and Resolution
Dynamo performs conflict detection using vector clocks. Clients send update requests containing a context (vector clock information). If multiple clients perform concurrent updates, a conflict occurs. Subsequent reads detect these divergent versions and return all of them to the client.
Application-specific reconciliation is possible; for example, the shopping cart service merges cart versions using its own logic. For other use cases like session management, a simple "last-write-wins" policy may be used. This flexibility allows each service to choose the most appropriate resolution strategy for its business requirements.
Optimizations in Production
Balancing Performance Tuning and Durability
At Amazon, SLAs are defined at the 99.9th percentile, and for most Dynamo services, 99.9% of read/write operations must be executed within 300ms. Achieving high performance on standard hardware is not easy, but Dynamo achieves latencies of less than 200ms at the 99.9th percentile through various optimizations.
To optimize the trade-off between performance and durability, Dynamo implements the following two optimizations:
- In-memory object buffering: Allows reads to be served from the buffer instead of storage.
- Durable writes: Performs a durable write to only one replica, ensuring durability without affecting the performance of write operations.
With these optimizations, even a small buffer (1,000 objects) improves the 99.9th percentile latency by fivefold.
Background vs. Foreground Task Management
The issue where background tasks such as replica synchronization and data handoff impact foreground operations is resolved through an admission control mechanism. Background tasks reserve slices of shared resources, and the number of slices is adjusted based on foreground performance.
The admission controller continuously monitors resource access and limits background task activity when latency approaches a threshold.
Coordination Between Client-driven and Server-driven
There are two approaches to request coordination.
- Server-side state machine (default)
- Client-driven coordination (moving the state machine to the client node)
In client-driven coordination, the membership state is downloaded every 10 seconds, and coordination is performed locally. This eliminates the need for a load balancer and reduces network hops. Measurements show an improvement of about 30ms at the 99.9th percentile and 3-4ms on average.
Practical Implementation Considerations
Comparison of Partitioning Strategies
Dynamo's partitioning evolved through three strategies.

https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf
| Strategy | Method | Key Characteristics | Advantages | Disadvantages |
|---|---|---|---|---|
| 1 | T random tokens per node and token-value partitions |
• Each node selects tokens randomly • Partitioning based on token values |
• Simple implementation • Random distribution |
• Full scan required when a new node joins • Merkle tree recalculation when key ranges change • Complex archiving |
| 2 | T random tokens per node and equal-sized partitions |
• Maintains random tokens while • Adopting equal-sized partitions |
• Decoupling of partitioning and placement • Placement scheme can be changed at runtime |
• Still depends on randomness • Issues with token selection optimality |
| 3 | Q/S tokens per node and equal-sized partitions |
• Strategic token placement (Q/S method) • Token redistribution during node join/leave |
• Best load balancing efficiency • Membership information size reduced by 3 orders of magnitude • Fast bootstrapping and recovery • Easy archiving |
• Token redistribution overhead |
Comparison results show that Strategy 3 achieves the best load balancing efficiency and reduced membership information size by three orders of magnitude. It also enabled faster bootstrapping/recovery and made archiving easier.
Practical Operational Challenges
The primary challenge is load balancing, with an imbalance rate of about 20% during low load and 10% during high load. Under high load, many popular keys are accessed, resulting in even distribution, but under low load, access to a small number of keys causes imbalance.
Other operational challenges include:
- Node addition time: Can take up to one day during peak periods.
- Overheads from Merkle tree recalculation and gossip communication.
While operational complexity is a barrier to adoption, cloud-based managed services can mitigate these problems.
Conclusion
Amazon's Dynamo achieves a highly available key-value store by combining various distributed systems techniques. It demonstrates that an eventually consistent store can be used for demanding applications in production environments; in actual operations, 99.9995% of requests received successful responses, and no data loss occurred.
The primary advantage of Dynamo is the flexibility of tuning via the (N, R, W) parameters. By exposing consistency and reconciliation logic to developers, applications can choose the solution that best fits their own business requirements.
Dynamo serves as a crucial foundation for the design of scalable, highly available key-value stores in the cloud computing era, and its design principles and lessons continue to influence many modern distributed database systems.

Discussion