Key-Value Store System Design
Cache write policies and a Dynamo-style store design. Compare the balance of read, write, and memory requirements in a concrete workload before choosing either.
Cache write policies
Dynamo-style design
The standard design for a distributed key-value store with put(key, value) and get(key), favoring availability, follows Amazon’s Dynamo paper.
Trade-offs to state in an interview:
- Consistency during partitions: this design chooses availability; see CAP and PACELC.
- Quorum values per workload: W = 1 for fast writes that tolerate loss, R = 1 for fast reads that tolerate staleness.
- Conflict handling: whether the application can merge versions, such as a shopping cart taking the union of items, decides whether version vectors are worth their cost.
The mechanisms are explained in data at scale: coordination and logical clocks, indexes and storage engines, and consistent hashing in the options table.
Questions to develop
Clarify the failure behavior, consistency, and workload that would favor each cache write policy, and how the policies above apply when the store is used as a cache.
Use the case template when developing a full store design.
Library sources
- DeCandia et al. 2007, Dynamo: Amazon’s Highly Available Key-value Store – the design in Dynamo-style design
- Xu 2020, System Design Interview: An Insider’s Guide – chapters 5 and 6, consistent hashing and a key-value store
- Educative 2023: key-value store, Grokking Modern System Design Interview