KatInterview

Design a Distributed Key-Value Store with Range Scan Support

System DesignModel answer
HardModel answerSystem Designdistributed-systemsstorage-enginesreplication

Last updated

Design a horizontally scalable, fault-tolerant key-value store that supports high write throughput, low-latency reads, and efficient range scans across multiple data centers.

Distributed Key-Value Store with Range Scan Support

You are tasked with designing a persistent, distributed key-value store meant to run across multiple data centers. The system must handle heavy write traffic while keeping read latency low, and it must support both point lookups and range queries efficiently.

Functional Requirements

  • put(key, value) — insert or update a key-value pair
  • get(key) — retrieve the value associated with a key
  • delete(key) — remove a key-value pair from the store
  • scan(start_key, end_key) — return all key-value pairs whose keys fall within a given range, in sorted order

Non-Functional Requirements

  • Availability: the system must keep serving requests even when individual nodes fail
  • Scalability: the system should handle petabyte-scale data and millions of requests per second
  • Consistency: choose a consistency model, state it explicitly, and justify the trade-offs

What your design should cover

  1. Partitioning strategy — how do you distribute data across the cluster, and how does the cluster handle nodes being added or removed?
  2. Storage engine — which on-disk data structure best fits the workload, and why?
  3. Replication and fault tolerance — how does the system survive node and zone failures without losing data?
  4. Client API and inter-node communication — what do the interfaces look like, and how do clients find the right node?
  5. Performance optimization — how do you make range scans efficient, and how do you manage background maintenance work like compaction?

Take roughly 45 minutes. Start by clarifying scale and constraints before drawing any architecture. Examiners will pay attention to how your partitioning choice interacts with range scans, so address that connection explicitly.

Hints

Hint 1

The scan requirement is a trap: if you partition by hashing keys, range queries must fan out to every node. Think about what partitioning strategy preserves key order.

Hint 2

For a write-heavy workload, compare how an LSM-tree and a B-tree handle disk I/O differently — specifically around sequential vs. random writes and read amplification.

Hint 3

Raft gives you a clean story for per-range replication and leader election, but synchronous cross-region quorums add real latency. Be prepared to discuss how to handle the multi-DC trade-off.