How would you design a distributed key-value store?
Why Interviewers Ask This
This question targets practical, hands-on experience with System Design. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.
Answer
A distributed key-value store stores key-value pairs across a cluster of nodes. Design like Redis, DynamoDB, or Dynamo (Amazon's paper). Requirements: put(key, value), get(key), delete(key); horizontally scalable; fault tolerant (N failures tolerated); configurable consistency. Partitioning: consistent hashing — place nodes on a virtual ring; keys are assigned to the first node clockwise from the key's hash position. Virtual nodes (vnodes) per physical node for even distribution. Replication: replicate each key to the next N nodes clockwise. Replication factor N=3 is common. Any of the N nodes can serve reads/writes. Consistency (CAP trade-off): Quorum reads/writes — W write replicas must acknowledge; R replicas must respond for a read. W + R > N guarantees reading the latest write. Common: N=3, W=2, R=2. Lower W → faster writes, lower consistency. Conflict resolution: last-write-wins (LWW) using timestamps (risk: clocks skew); vector clocks (track causality, detect concurrent writes); CRDTs (conflict-free replicated data types — auto-merge without conflicts). Gossip protocol: nodes periodically exchange state with random neighbors — eventual propagation of membership info without central coordinator. Failure detection via heartbeats + phi accrual failure detector. Read repair: during a read, if replicas disagree, fix inconsistency. Merkle trees: efficiently detect differences between replicas for synchronization.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real System Design project.
Previous
How would you design a Twitter/social media feed?
Next
How would you design a notification system?
More System Design Questions
View all →- Intermediate How would you design a URL shortener like bit.ly?
- Intermediate How would you design a rate limiter?
- Intermediate How would you design a Twitter/social media feed?
- Intermediate How would you design a notification system?
- Intermediate What is the CAP theorem and how does it apply to database choice?