· SWE Editorial · System Design · 6 min read
Design a Key-Value Store: Scaling Bottlenecks
How a distributed key-value store breaks under scale: hot keys, rebalancing pain, cross-region replication latency, and compaction storms, with concrete mitigations interviewers expect.
Every key-value store design looks clean at low scale — a consistent-hashing ring, an LSM tree per node, quorum reads and writes. The interview signal that separates senior from staff-level candidates is what happens when you push that clean design toward real production scale: which component breaks first, why, and what you’d change. This article covers the four bottlenecks interviewers most often probe: hot keys, rebalancing, cross-region replication, and compaction storms.
Hot Keys: When Uniform Hashing Isn’t Enough
Consistent hashing distributes keys uniformly across the ring in expectation, but real-world access patterns are rarely uniform. A single celebrity user’s profile, a viral product’s inventory counter, or a trending hashtag’s counter can receive orders of magnitude more traffic than an average key — and because that key still lives on one partition (or one replica set), the node(s) hosting it become a bottleneck regardless of how well the rest of the ring is balanced.
Mitigations, roughly in order of how often they come up in interviews:
- Key splitting / sharding a hot key: instead of
counter:product_123, write tocounter:product_123:shard_{0..9}distributed across multiple partitions, and sum shards on read. This trades read complexity for write scalability. - Read-side caching in front of the store: a small in-memory cache (even a single-node LRU) absorbing reads for known-hot keys can cut load on the underlying partition by orders of magnitude, since hot keys are read far more than they’re written.
- Local (in-process) caching with short TTLs on the client or edge layer for extremely hot, rarely-changing keys, accepting slightly stale reads in exchange for removing load entirely from the store.
- Adaptive/dynamic partitioning: detect hot partitions via load metrics and split them further (independent of the hash ring’s static assignment), a technique used by systems like HBase’s region splitting.
The interview framing to use: hot keys are a request-count problem, not a data-size problem — the fix is almost always about spreading access, not spreading storage, which is why simple re-sharding by key count doesn’t help.
Rebalancing: The Cost of Growing the Cluster
Consistent hashing famously limits reshuffling to roughly 1/N of the keyspace when adding the Nth node, but “limited” is not “free.” When a new node joins the ring, data must physically move from its neighbors to populate the new node’s assigned range, and until that transfer completes, reads for keys in transit must be served correctly from whichever replica currently holds valid data.
Bottlenecks and mitigations to name:
- Bandwidth and I/O contention during transfer: moving gigabytes of SSTable data between nodes competes with live traffic. Mitigate with throttled, rate-limited streaming of data during rebalance, and prefer transferring already-compacted, immutable SSTable files directly (cheap to stream, no re-serialization needed) over row-by-row replication.
- Virtual nodes smoothing the transfer: with virtual nodes, a single physical node joining takes over many small ranges from many different existing nodes rather than one large range from one neighbor, spreading the rebalance load across the cluster instead of concentrating it on two nodes.
- Read/write availability during transfer: use a hand-off period where the old owner continues serving reads/writes for a range until the new owner confirms it has fully ingested the data, avoiding a window of unavailability.
- Avoid rebalancing storms: adding or removing multiple nodes in quick succession (e.g., during an autoscaling flap) can trigger overlapping rebalances; production systems typically rate-limit how many rebalance operations run concurrently cluster-wide.
Cross-Region Replication: Latency vs. Consistency
Once a key-value store spans regions (for disaster recovery or to serve users closer to their data), the quorum-based consistency model from a single region gets expensive fast: a write requiring acknowledgment from a quorum spanning multiple continents pays round-trip latency measured in hundreds of milliseconds, not single-digit milliseconds.
| Approach | Consistency | Write Latency | Failure Behavior |
|---|---|---|---|
| Synchronous cross-region quorum (W spans regions) | Strong | High (bound by slowest required region) | No data loss on regional outage, but writes stall if quorum unreachable |
| Asynchronous cross-region replication (local quorum, async fan-out to other regions) | Eventual (cross-region) | Low (bound by local region only) | Possible data loss for the async replication lag window on a regional disaster |
| Per-key region affinity (“write where the user is”) | Strong locally, eventual globally | Low for the owning region, higher for others | Requires conflict resolution if the key is later written from a different region |
The interview-expected answer: most production key-value stores default to local quorum + asynchronous cross-region replication, accepting a small window of potential data loss during a full regional failure in exchange for keeping write latency low for the common case. Mention conflict resolution (last-write-wins by timestamp, or vector clocks to detect concurrent writes from different regions) as the mechanism needed once you accept eventual cross-region consistency — this is the natural follow-up question.
Compaction Storms: When Background Work Becomes Foreground Pain
As write volume grows, memtables flush more frequently, producing more SSTables faster than compaction can merge them. If compaction falls behind, three things happen in sequence: the number of SSTables per partition grows, read latency degrades (more bloom-filter checks and index seeks per read), and eventually the storage engine may throttle or reject writes to prevent unbounded SSTable growth (a defensive mechanism some LSM implementations call “write stalls”).
Mitigations to name:
- Leveled compaction over size-tiered when read latency predictability matters more than raw compaction throughput — leveled compaction bounds the number of SSTables per key range more tightly.
- Dedicated compaction I/O budget: rate-limit compaction throughput explicitly (bytes/sec) rather than letting it run unthrottled, trading slower space reclamation for protecting foreground read/write latency.
- Horizontal scale-out before vertical compaction tuning: if a single node’s compaction can’t keep up with its write rate, the more durable fix is often to add nodes and reduce the per-node write rate via better key distribution, rather than continuing to tune compaction parameters on an overloaded node.
- Monitoring SSTable count per partition as a leading indicator: a rising SSTable count is the earliest observable signal of a coming compaction storm, well before read latency visibly degrades — mentioning this as an operational metric is a strong signal of production experience.
Bringing the Bottlenecks Together
A pattern worth stating explicitly in the interview: hot keys and compaction storms are within-node or within-partition problems (fixed by better access patterns or I/O budgeting), while rebalancing and cross-region replication are cluster-topology problems (fixed by smarter data movement and tunable consistency). Framing your answer along this axis — is this bottleneck about one partition’s access pattern, or about how data moves across the cluster — gives the interviewer a clear signal that you’re reasoning systematically rather than listing memorized failure modes.
For worked numeric examples of each bottleneck (including how to estimate when a compaction storm becomes likely given a target write throughput), The 0-to-1 SWE Interview Playbook (Amazon: https://www.amazon.com/dp/B0H256Z1MF?tag=sirjohnnymai-20) includes a dedicated scaling-bottlenecks chapter with the exact follow-up questions staff-level loops use to probe this topic, updated for 2026.
Practice Prompt
Pick one bottleneck from this article and argue against your own mitigation: for hot-key sharding, what breaks if the shard count is wrong for the actual traffic skew? For asynchronous cross-region replication, what’s the blast radius of the async lag window during a real regional outage? Interviewers reward candidates who can stress-test their own proposed fix, not just state it.