TSTier SlateAll templates

Infrastructure primitives

Key-value store - quorums, and where the consistency knob sits

partition, replicate, and choose how much to wait for

  • System design
  • deep
  • 8 step walkthrough
  • 4 tables

Share

  • Facebook
  • X

What this board gets wrong on purpose

The tension

R + W > N guarantees that a read touches at least one replica that saw the write. It does NOT order two concurrent writes, so the coordinator regularly gets two versions back and something has to choose - last-write-wins discards one of them silently and stakes correctness on clocks that are not synchronised, while vector clocks hand the choice to an application that usually has no idea what to do with two shopping carts. Worse, the knob is per REQUEST and not per cluster: one ONE-level read in a hot code path makes the whole store behave as eventually consistent regardless of what operations configured, and nothing in the system reports that it happened. The deletes are the third trap - a tombstone that is garbage collected before a slow replica hears about it lets the deleted row come back.

Requirements

Ask these before drawing anything

  • What is the access pattern - get and put by a single key, or are there range scans and secondary lookups? A store that must answer "all orders for this customer, newest first" is a different design, and bolting a secondary index onto this one is the most common way to ruin it.
  • What does a stale read cost? This is the question the whole board turns on. If a stale read is merely annoying, the default can be ONE and the system is fast and cheap. If it is money or a permission, every read pays a quorum.
  • Can the application resolve conflicts? Vector clocks are only useful if somebody downstream knows how to merge two versions. If the answer is no, last-write-wins is the honest choice and its cost must be written down rather than avoided.
  • How large is a value, and is it ever appended to? Large values and growing values are different failure modes: one blows the row size, the other makes compaction never finish.
  • What is the delete volume? Deletes are writes here, and a high-delete workload is the one that turns compaction into the bottleneck.
  • Single region or multi? Cross-region quorums cost 80 ms per operation, which usually means the answer is local quorums plus asynchronous replication, which is a weaker guarantee and must be said out loud.

Functional

  • get(key) and put(key, value) on an opaque value, plus delete.
  • Tunable consistency per REQUEST, not per cluster: ONE, QUORUM, or ALL.
  • Replication factor of 3, configurable per keyspace.
  • A node may be added or removed without downtime and without moving more than its share of the token space.
  • Survive the loss of any single node with no loss of availability for reads or writes at QUORUM.
  • Repair divergence automatically - on read, in the background, and after an outage.

Non-functional

  • p99 of 10 ms for a QUORUM read, 15 ms for a QUORUM write, measured at the coordinator.
  • 99.99 percent availability for QUORUM operations, which given N=3 means surviving one replica down per partition and no more.
  • Durability: a write acknowledged at QUORUM must survive the immediate loss of any one node. That is a statement about fsync of the commit log, not about replication, and the two are frequently confused.
  • Linear scale-out: doubling the nodes doubles the throughput and halves the per-node data, with no rewrite of existing data beyond the moved token ranges.
  • No single point of failure and no elected leader on the request path.

Out of scope, and each of these is a whole other system

  • Multi-key transactions. Not supported, not partially supported, and not emulated in the client.
  • Secondary indexes. A global secondary index over a partitioned store is a distributed transaction wearing a friendly name.
  • Range scans across partitions. The partitioner destroys ordering by design.

The rest of this board

Board preview

Available on Tier Slate

This page publishes the question. The answer — 5 more written pages, an 8-step narrated walkthrough and a 4-table schema — is the board itself, and it opens in Tierslate.

  • 5written pages
  • 8walkthrough steps
  • 4tables30 columns

5 pages behind this one

  • Capacity estimation
  • Storage estimation
  • Availability
  • How it works
  • Deployment plan
Open this board in TierslateBrowse every board

More boards

The building blocks an interview asks you to build from scratch.

  • URL shortener - one write, a million reads
  • Distributed cache - the ring, and what a node leaving costs
  • Rate limiter - token bucket, and where the counter lives
  • Unique ID generator - 64 bits, and two facts nobody can check
  • Web crawler - a frontier, and the trap of crawling forever
All 50 templatesOpen Tierslate
Tierslate

tierslate.com

HomeTemplatesPrivacyTerms