Design a Key-Value Store

Quick Overview

Design a distributed key-value store like Bigtable or DynamoDB. Cover consistent hashing, replication strategies, read/write quorums, compaction, and tunable consistency levels.

Google
System Design
Software Engineer
Google
Software Engineer
Onsite
System Design
Hard

0


Design a distributed key-value store like Bigtable or DynamoDB. Cover consistent hashing, replication strategies, read/write quorums, compaction, and tunable consistency levels.

Google built Bigtable and Spanner, so interviewers expect depth on how a distributed key-value store partitions, replicates, and compacts data. They check whether you can explain consistent hashing, quorum reads and writes, conflict resolution, and how tunable consistency changes latency and availability.

What the Interviewer Expects
  • Define API and requirements, including tunable consistency per request
  • Partition with consistent hashing and virtual nodes
  • Replicate N ways and explain R + W > N for strong reads
  • Describe the write path: commit log, memtable, SSTables, and compaction
  • Handle failures with hinted handoff, read repair, and anti-entropy
  • Discuss conflict resolution with timestamps or vector clocks
Key Topics to Cover
Consistent hashing
Replication and quorums
LSM trees and compaction
Tunable consistency
Failure recovery
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • What happens to reads and writes during a network partition with N=3, R=2, W=2?
  • How do you rebalance data when a node joins or leaves?
  • Which compaction strategy would you pick for a write-heavy workload, and why?
  • How would you detect and resolve concurrent writes to the same key?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Functional Requirements

  1. Key-Value Storage: Users can store and retrieve values associated with unique keys.
  2. CRUD Operations: Support for Create, Read, Update, and Delete operations. ...
Capacity Estimation

Capacity Estimation

  • Expected Users: Assume 1 million active users.
  • Requests per User: Each user generates approximately 10 requests per minute.
  • Total Requests per Minute: 1,000,0...

Submit Your Answer
Markdown supported