You design a distributed system by making six decisions in order — where state lives, how many copies exist, how those copies agree, where ordering comes from, what a read is allowed to see, and what the system refuses under overload — because each answer constrains the next one.
Page one for that query is a bag of nouns: replication, sharding, consensus, CAP, consistency models. Distributed system design gets taught that way, and you cannot apply a bag of nouns, because the order is the entire argument. Choose the copy count before the state model and you have spent the decision on a number your state model invalidates.
If you came here for an interview answer, or to be handed a design me a system
exercise, close the tab. You own something in production, and someone has asked you to spread it out. the system design procedure is the checklist for one box. This is the ordered procedure for many machines, which is what distributed system design looks like when you write down the order.
Here is the sequence, one line each, so you can see the shape before the detail.
- Where your state lives, and how you cut it up.
- How many copies exist, and which failure domains hold them.
- How those copies agree, and what happens when they cannot.
- Where your ordering comes from, and how much you trust your clocks.
- What a read is allowed to see, per read class.
- What your system does when it cannot do everything.
Start at decision four and you will pick a consistency level you cannot compute, because the answer depends on a clock bound you have not set yet.
The evidence runs through one system, because CockroachDB is one of the few distributed systems whose designers published their decisions layer by layer, with the reasons and the reversals. Every step below maps to a real decision in CockroachDB's own documentation, and every figure traces back to a vendor doc, an engineering book, or a published analysis. Where a number is the vendor's own measurement, I attribute it that way.
Four things this post refuses to develop, each named once: the CAP theorem and its arithmetic, the availability budget and its math, the consistency-model taxonomy, and the internals of consensus. Each is named at the seam where it matters to you.

When is a distributed system the wrong answer?
Until distribution is forced on you, one process is still the correct architecture, and none of the six decisions start until you are past that. The honest counterweight is ecommerce architecture at 100 users: one server, one process, a file-backed store, and a bill you can read. That post is right at the scale you actually operate at.
Distribution becomes forced on you when one of three things happens: you have outgrown the machine, the region, or a durability requirement that one failure domain cannot satisfy. Before that, every step in this post is cost with no return to you. A replicated system is a deliberate set of trade-offs against a single store, and until you hold one worth trading away, you are paying the bill early.
Decision 1 — where does state live, and how do you cut it up?
Pick your partition key and your partition unit size, and write both down. Everything downstream of your two answers is bounded by them. Every other decision is a function of that, and a copy count means nothing until you know what a copy is a copy of.
Four ways to cut your state, and they are the whole menu:
- One node, one writer, one store. The cheapest thing you can build, and it stops at one machine.
- Key range. You partition a sorted map into contiguous ranges. Your ranges split when they grow and merge when they shrink, so moving your data is a copy.
- Hash. You get an even spread by construction. You give up range scans and ordered scans of the whole key space.
- Geography or tenant. You get local reads, and hot keys and uneven load land on you to handle.
In CockroachDB, all user data and nearly all system data live in one monolithic sorted map of key-value pairs, cut into contiguous chunks called ranges, and every key lives in one range (distribution layer). A range splits in two when it reaches the maximum size, and merges back with its right-hand neighbour when it falls below the minimum. The docs defend merging on two grounds: you pay a fixed per-range overhead on every query, and you rebalance a few large ranges faster than many small ones. The shipped values for you are a split at 512 MiB and a merge below 128 MiB (replication controls). Two 18-bit levels of metadata address 236 ranges, each addressing 226 bytes, which gives 262 bytes — 4 EiB of key space.
Splitting a key range costs you your range scans. A table and its secondary indexes start in one range, and after a split you find them in different ones. One logical write then fans out across independent replication groups. You traded a clean key space for a write that touches several quorum sets at once, and you did it without choosing to.
The second cost bites you in quarter three. A primary key that always increases puts every write on the tail of the same index, and you are then limited to the throughput of one range, no matter how many nodes you add. The docs have a name for it and a fix you can use: hash-sharded indexes, or a random UUID primary key (hotspots). You will not notice it until a quarter of dashboards look wrong.
And the counter-intuitive one: your unoptimised design is often the cheaper one. The same hotspot documentation notes that index hotspots can paradoxically improve CPU cycles per write, because a moving write tail produces sorted files with less overlap. The same page then says the boost has a limit, and that relying on it is problematic. Treat that as a trap. You are looking at a benchmark rewarding the wrong thing, and the improvement stops existing the moment you depend on it.
One clarification before you go further. Where state lives inside a system is not a question about how many services you have. That argument, in both directions, belongs to monolith vs microservices, not to you. The event-driven and queue-versus-stream arguments that go with decoupling your read path are not developed here.

Decision 2 — how many copies, and which failure domains hold them?
Pick a replication factor and a placement rule. Both are configuration, and both change your write latency the moment you set them. You compute your tolerated failures as (replication factor − 1) / 2: three copies you buy tolerate one failure, five tolerate two. Three is also the smallest number that can form a quorum, which is why a write path that accepts concurrent writers needs three nodes at all.
You get sensible defaults if you accept the vendor's: CockroachDB ships num_replicas at 3 for table data, and 5 for the system database and the meta, liveness, and system ranges. A multi-region database configured to survive region failure defaults to 5, split between voting and non-voting replicas. The vendor's production checklist turns that arithmetic into a node count you can size against. At least 3 nodes across 3 zones survive one zone failure. At least 5 nodes at replication factor 5 survive two node failures, and at least 3 regions survive one region failure. Google's SRE book gives you the general form: 2f+1 replicas tolerate f failures, and 3f+1 if you need to survive Byzantine faults.
Placement decides the rest, and placement is the half you skip. Copies that share a zone share the failure you thought you had bought against. Your failure domain is the number; the zone is where you put it. You cannot buy that failure back with node count alone, so you write the placement rule down next to your replication factor.
Why three is the floor, and what a fourth copy actually buys
You may think three is arbitrary. It is not, and the release notes tell you why. Before v21.1 every CockroachDB replica voted, so raising the replication factor paid for more replicas inside the consensus group and more write latency, whether or not you read from the extra copies. Non-voting replicas were introduced so you could add a copy that follows the log and serves reads without joining the quorum (replication layer).
Copies you cannot read from are pure insurance, and you should know which kind you are buying. A non-voting replica is a cheap read source and a full replica. A voting replica is both, plus a vote — and a vote you pay for in latency on every write. If your reason for a fourth copy is read scaling, say so, because that reason is served by a mechanism that does not slow your writes.
How many copies you need is one decision inside a larger availability budget. How to design a highly available system owns the budgeting. This post owns the placement arithmetic, because placement is what changes your write path.
Decision 3 — how do copies agree, and what happens when they cannot?
Choose per partition whether a write needs a majority to acknowledge now, or can be accepted and reconciled later — and know that this is the one decision in the sequence you cannot take back cheaply. You can tune everything else in production. This one moves data.
Four mechanisms:
- Consensus, as in Raft or Paxos. A majority must acknowledge. You get blocking, correct, and an expensive write path.
- Quorum reads and writes without a consensus log. This is the Dynamo family. You get speed, and the quorum arithmetic alone decides what can go wrong when your replicas disagree.
- Single leader, followers replicate asynchronously. You get simplicity, and a follower read can be stale.
- Last-writer-wins by timestamp. You get the cheapest option, and you inherit a dependence on clocks you do not actually trust.
Your write goes to a Raft leader, and commits only when a quorum of replicas acknowledge. The docs state the consequence in one sentence: when one of your writes does not achieve consensus, forward progress halts. That halting is the CAP theorem post's subject, not this one's. CockroachDB runs Raft, and how its leader gets elected, or how its log replicates, belongs to that protocol's own literature.
What matters here for you is a structural choice, not the theorem. CockroachDB fuses leadership with read serving, and that fusion is the part you have to price. Your leaseholder is the replica that serves all reads and coordinates all writes, and the Raft leader is the same replica except during a lease transfer. Leader leases let your leaseholder answer a consistent read without a second round of consensus. Commit latency is the round trip to the leader plus the round trip from the leader to a follower, which is why leader placement dominates what your users feel.
Two counter-intuitive results fall out of that shape. First, the consensus layer is often not your slow part: Google's SRE book says flatly that the conventional wisdom holding consensus too slow is simply not true, and that large datasets and wide geography are what actually hurt you. Second — the one that costs you an outage — fusing read serving with leadership concentrates risk. Under the previous leasing regime, a leaseholder partitioned from its followers but still heartbeating the liveness range produced an indefinite outage lasting as long as the lease was held by that node. The fix was node health from a quorum of stores, not a single liveness range. Look for the same shape anywhere you run a heartbeat.
Google reaches the same conclusion from the other side: leader election with heartbeats and timeouts is a reformulation of the asynchronous consensus problem, and solving it with timeouts is unsound, because a slow network is indistinguishable from a dead node. Three case studies in the SRE book end in split brain, human escalation, or wrong group membership — all teams like yours buying consensus with a timer you already had.
Do not skip this decision. It is the one that moves data when you change your mind, and you learn how much data only after you have started moving it.

Decision 4 — where does your ordering come from, and how much do you trust your clocks?
Choose an ordering mechanism, write down its bound, and treat that bound as a correctness input rather than a performance knob. In my judgement this is the decision that gets skipped, and it is the one where you discover the cost in places you never budgeted for.
Four sources of order, in increasing order of infrastructure cost:
- Synchronised hardware clocks with a tight bound. You get the strongest guarantees and the most expensive datacenters.
- NTP. You get something cheap and much looser. Its bound enters your latency budget whether you planned for it or not.
- Hybrid logical clocks, with a retry when you are uncertain. You avoid waiting after writes, and you pay in retries on reads.
- A logical counter per partition, and no global order at all. You get the cheapest option, and you lose
after
across partitions.
CockroachDB's engineering blog treats this as the central question of your design, and its summary sentence carries the contrast: While Spanner always waits after writes, CockroachDB sometimes retries reads
(Living without atomic clocks). Your transaction picks a provisional timestamp from local wall time, plus an upper bound equal to your cluster's maximum clock offset. What you have is an interval of uncertainty, not a timestamp. A read landing inside the interval restarts the transaction at a higher timestamp, and the window shrinks on each restart.
The bound is concrete, and it is the vendor's characterisation of NTP, not a measurement of your own datacentre: roughly 100 to 250 ms for NTP, against the 7 ms upper bound that same blog cites for Spanner's TrueTime. Under NTP, no transaction of yours should retry for more than 250 ms for clock reasons.
The bound you configure is the bound you enforce
You get a default maximum clock offset of 500 ms, and your node shuts itself down when it detects its own clock out of sync with at least half the other nodes by 80% of that maximum. You find out how badly you set the bound through a node that took itself out of service. For clusters on the multi-region abstractions, Cockroach Labs recommends lowering --max-offset to 250 ms. What the bound buys you is in the operational FAQs: skew outside your configured bounds can violate single-key linearizability between causally dependent transactions. What that costs comes from a third party, and Jepsen's 2016 analysis is the honest place to read it — higher thresholds increase the maximum allowable latency for read operations which conflict with a write, though your reads impose no hard floor, because unconflicted transactions proceed faster.
Your clock is a correctness input, not a monitoring line. Most teams file skew under observability. In your system whose ordering comes from wall time it is a failover event, because the enforcement mechanism is your node taking itself out of service.
And the intuitive direction is backwards. Your instinct is to loosen the bound for speed — a wider tolerance means fewer shutdowns and fewer retries. The recommendation goes the other way, and the scope is part of the claim: the docs call the tighter 250 ms bound especially helpful for lowering the write latency of Global Tables. Lowering your clock tolerance makes writes faster on Global Tables, which is the counter-intuitive result of the section. That is a scoped result, and you do not get to assume it on a cluster holding no Global Tables.
The general lesson, without a vendor: if your ordering comes from clocks, you have chosen a distributed-systems problem whether you meant to or not, and you now have to budget for it in latency and in shutdowns. That is the part of how to design a distributed system you get to decide in a design review instead.
Decision 5 — what is a read allowed to see, per read class?
Write your staleness budget per read class, not one global setting. A dashboard, a checkout page, and a balance check do not get the same answer, and a single global knob forces you to pick the strictest one and pay for it everywhere.
Four shapes, per endpoint:
- Every read strongly consistent. You get the simplest contract. One leaseholder serves the partition, and your read throughput is capped by that one node.
- Every read allowed to be stale. You get the fastest reads, and you have to design the staleness away at the product level.
- Per-read-class staleness, bounded or exact. More work to specify, and it is the only option that lets your reads scale.
- Strong reads from any replica, paid for with slower writes. You get it, and you move the cost onto your write path on purpose.
CockroachDB defaults you to the first option: strongly consistent reads are what you get by default, and the most common type, served through the leaseholder, under a user-facing slogan of no stale reads
. Two opt-in mechanisms sit on top: exact staleness, where you name the timestamp, and bounded staleness, where you name an offset — both only in read-only transactions.
The legitimate-use test comes from the vendor, in two separate posts, and that is the list you have to write. Load the Hacker News front page: it does not matter much whether you see the latest ranking of links or the ranking from a few seconds ago, because you are going to refresh the page anyway (follower reads). Somebody deposits a check for you, your bank texts you about it, and you go online to see your balance — and if that balance is stale, you will not be calm about it (consistency model). You write the list per endpoint.
Closed timestamps — how a follower becomes a reader
Each range tracks a closed timestamp: a promise from your leaseholder to its followers that it never accepts a write at or below that value. A follower can therefore serve any read at or below its closed timestamp, which turns your followers from dead weight into readers you can actually use (follower reads). The current policy targets closing timestamps three seconds in the past.
A larger closed-timestamp interval reduces retries on your long-running write transactions, and raises the lock latency you pay while it closes.
Turning the staleness knob down to be fresher
makes your write path worse. You reach for a smaller interval because you want newer reads, and you get more retries on long writes and higher lock latency instead. Freshness is bought on the read side and paid for on the write side, and that is the shape of the decision.

Buying read latency with write latency, on purpose
The aggressive version inverts that direction on purpose. Global Tables close timestamps a few hundred milliseconds in the future, which forces your writers to write at future timestamps and pay a commit wait, so your reads in every region are strongly consistent and local (Global Tables). The vendor's own measured claim is that this cuts the tail latency of consistent reads from hundreds of milliseconds to single-digit milliseconds, and your writers pay it alone.
One hard constraint carries into every option above, and that decides your read architecture first. You cannot spread consistent reads across replicas for free, because your leaseholder's throughput caps the range's consistent-read throughput. Non-voting replicas, follower reads, and global tables exist to relieve the one node you are pinned to.
Which is why your read path, not your write path, is usually the bottleneck. Adding write replicas does nothing for your reads: every consistent read still goes to one node, and that node's throughput is the range's consistent-read ceiling. Read-your-writes, monotonic reads, bounded staleness, linearizability, serializability, and strict serializability are the labels for the knobs you just set — the taxonomy behind those names belongs to the consistency posts, not here.
Decision 6 — what does the system do when it cannot do everything?
Write your degradation order down before you need it, then implement the refusal. Your system that queues everything has chosen to fail slowly, and it will fail slowly during the hour you cannot think clearly.
Five options, and they combine:
- Queue everything and let latency absorb the overload.
- Shed at the edge, per endpoint.
- Prioritise by criticality — node-health operations first, then your lock holders, then user work, then background work.
- Refuse a whole class of request once you cross a threshold.
- Put a circuit breaker per replica, so one bad replica does not hang your request.
CockroachDB's admission control sorts your operations into priority queues per node and prefers work critical to node health and transactions currently holding locks, so contention drops and locks release sooner (admission control). Almost every operation that consumes CPU or storage IO is subject to it, which is the part that surprises you: SQL, bulk imports, deletes, backups, restores, schema changes, consensus log writes, changefeeds, and intent resolution. You mark sessions critical, regular, or background. Replication is paced separately from foreground work — regular writes at the rate of your replica quorum, background replication at the rate of the slowest replica, and that second rule is what stops a node you just added from being slammed by its own backlog.
The circuit breaker, and the hole in it
When a range becomes temporarily unavailable, a per-replica circuit breaker trips after 60 seconds by default and returns a ReplicaUnavailableError instead of hanging your request. CockroachDB is explicit about the hole: the breaker does not trip if all the replicas of the range are unavailable. A breaker that protects you from one sick replica gives you nothing when the whole range is down, so the refusal you write for that case has to live somewhere else.
The storage layer keeps its own degradation ladder, and you want one too. At 92.5% disk full a store is excluded as a rebalancing target, and at 95% your store is excluded from allocation and its replicas are actively moved off. Admission control is designed for your node holding more than 32 runnable goroutines per CPU — a condition it responds to, not a signal it emits.
The honest limit is in the vendor's own words, and you inherit it deliberately or by surprise. Admission control is per node, not per cluster, and there is no preemptive rejection when your work queues are long. Aggressive client timeouts can leave your system doing partial work at low throughput, and it then neither refuses cleanly nor runs at speed.
Two results from the overload literature, applied sparingly. Retries multiply: three retries at each of three layers turns one user action into 64 attempts, and the AWS Builders' Library gives the same warning from the other direction — a five-deep stack with three retries per layer multiplies to 243 times the original load. And a small failure rate becomes a catastrophic one: in Google's cascading-failures chapter, 1,000 frontend threads with a 100-second deadline and 5% of requests never completing produces an 80.4% error rate, because the stuck requests hold the threads your good requests need. Your degradation order has to include your own timeouts, or your timeouts will defeat it.
After the six — prove the design, do not assume it
A decision you cannot test is a belief, so run a continuous verifier and let it panic when the replicas disagree.
CockroachDB runs an independent consistency checker on every node (Trust, but verify). Your checker agrees a snapshot identifier with the replicas, computes a SHA-512 checksum on the leader and followers in parallel, compares them, and panics or logs on a mismatch. The checker runs in a continuous loop over a 24-hour cycle, and your checker found real bugs: non-deterministic protobuf map wire encodings, writes to replicas outside the consensus log, and time-series data merged incorrectly when a read landed on the leader. None of the three shows up in the source you read, which is why a design review would not have caught them either. The same post also stripped floating-point additions out of replica replay, and that one is not a fourth find — it was a defensive measure taken while fixing the merge bug, because floating-point addition is non-associative and nobody wanted your design resting on that.
Someone else then tested it outside the vendor, and found more. Jepsen's analysis of CockroachDB beta, published in 2017 and the only CockroachDB entry in its index, found two bugs, and only one was a serializability violation. That one came from timestamp collisions in the timestamp cache. The other applied a transaction twice, because an RPC retry turned an indeterminate network failure into an apparent definite failure. That one is now an explicit error type, which tells you the operation cannot be retried transparently.
The part that transfers is the discipline, not the tooling. Jepsen's own methods — opaque-box testing of real binaries, failure modes other suites skip, generative testing against a model — you can run against your own system. And Kleppmann's point is why you care: almost no shipping database can be classified rigorously under the two-letter vocabulary, because the definitions are narrow and real systems land between the buckets. So argue about mechanism, because labels do not survive contact with an implementation.
Every one of these bugs arrives as somebody else's incident at 3 a.m., and you meet the design error behind it as triage work. That is how to triage a production incident.
What to take away — the sequence, and what distributed system design is not
Take the order. Every component below that order is a consequence of it, not a co-equal choice you can pick from a menu.
- State. Your partition key and unit size. Everything else is bounded by them.
- Copies. Replication factor and placement. Tolerated failures are (RF − 1) / 2.
- Agreement. Consensus, or quorum without a log. Per partition, close to irreversible.
- Ordering. Mechanism plus a bound. A correctness input, enforced by shutdown.
- Reads. A staleness budget per read class, not one global setting.
- Overload. Your degradation order, written before the incident. Then the refusal you implement.
Six decisions in order, and you can tune five of them in production. One moves data. That is the content of how to design a distributed system — an order and six written-down answers inside it, instead of a vocabulary you cannot apply in sequence.
What you are not getting here is deliberate. How to Design a Highly Available System owns the availability budget and its math. The CAP Theorem Explained with Real Examples post owns the arithmetic behind the halting sentence in decision three. Consistency vs Availability: How to Choose and Strong vs Eventual Consistency own the taxonomy. Event-Driven Architecture and Queues vs Streams own the decoupling option named once in decision one. How to Make Better Architecture Decisions and Architecture Decision Records own record-keeping. Modular Monolith vs Microservices owns the module-boundary argument. Each was named once and deferred, so you get one question: in what order do you decide the things that make a system distributed.
Related Reading
System Design: A Practical Guide for Software Engineers
Search system design and you get a diagram: a load balancer, a cache, a queue, a database, and a glossary.
Ecommerce Architecture at 100 Users: One Server, One Process
Why does every ecommerce architecture guide assume you have a team?
Monolith vs Microservices: The Trade-offs
The monolith vs microservices results are two-column tables, and the tables are the problem monolith vs microservices is