← Questions

Design a disk-backed key-value store under heavy contention

0
SnowflakeSystem designLast asked Mar 2026

A system design interview question asked in Snowflake's system design round, last asked Mar 2026. It tests key-value stores, concurrency and storage.

Design a key-value store that keeps its data on local disk and serves many concurrent readers and writers on one machine. Values can be large, and some keys are hot: many clients read and write the same few keys at the same moment. The store must stay correct and fast under that contention.

Requirements

  • Functional: get(key), put(key, value), delete(key); values from a few bytes to many megabytes; data survives a process crash or power loss once put returns.
  • Non-functional: high read and write throughput with many threads, low tail latency on hot keys, bounded memory (the data set is larger than RAM), fast restart.

Clarifying questions

  • What is the read/write mix, and how skewed are the keys?
  • How large are values, and is the data set much bigger than memory?
  • What does a reader need to see: the latest committed value (linearizable per key), or is a slightly stale value acceptable?
  • Is durability required on every put, or may writes be batched (group commit) at the cost of a small loss window?
  • Are range scans or multi-key transactions needed, or only single-key operations?

What a strong answer covers

  • An on-disk layout chosen and justified: an append-only log with an in-memory index (log-structured, Bitcask style), an LSM tree, or a B-tree with pages; where large values live (separated from the index so it stays in memory).
  • The write path and durability: write-ahead log, fsync policy, group commit to amortize syncs, and checksums on records.
  • Concurrency control that does not serialize everything: lock striping or per-key locks, reader-writer locks or MVCC so readers never block on writers, and copy-on-write index updates.
  • Hot keys specifically: why a single lock on one key collapses throughput, and options such as coalescing concurrent writes, versioned values so reads are lock-free, and caching the hot values.
  • Caching: a block or value cache sized against memory, its eviction policy, and how it stays consistent with writes.
  • Crash recovery: replaying the log or WAL, discarding torn writes by checksum, and keeping restart time bounded with checkpoints or index snapshots; compaction or garbage collection of overwritten values without stalling foreground traffic.
  • How you would measure contention (lock wait time, p99 latency per key, profiler) and the order in which you would remove it.

Follow-ups

  • One key receives half of all writes. Walk through what happens in your design and how you fix it.
  • Compaction is running while traffic peaks. How do you keep it from hurting latency?
  • How would you add range scans, and what does that change in the layout?
  • How do you test that a crash at any point leaves the store consistent?

Where it's asked

What it tests

key-value stores · concurrency · storage · durability

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing