← All Problems
HardDatabases45 min

Design a Distributed Key-Value Store

Design a distributed key-value store like DynamoDB or Cassandra that provides high availability and partition tolerance.

AmazonGoogleAppleNetflix

Functional Requirements

  • Get/put operations by key
  • High availability: always writable
  • Tunable consistency (strong or eventual)
  • Automatic partitioning and replication
  • Handle network partitions gracefully

Steps (0/6)

Step 1: Clarify & CAP Theorem

**CAP Theorem**: In a network partition, you must choose between Consistency and Availability. - **CP system** (e.g., HBase): Rejects writes during partition to maintain consistency - **AP system** (e.g., Cassandra, DynamoDB): Accepts writes during partition, resolves conflicts later Most distributed KV stores choose AP with tunable consistency. Ask: What does the use case need?

Key Points

  • CAP: can only guarantee 2 of 3 (Consistency, Availability, Partition tolerance)
  • AP with tunable consistency is the most common choice
  • Tunable: allow per-request consistency level
  • Network partitions are inevitable - must handle them
1 / 6