Interview: everything is on the strongest consistency and far requests crawl
Which features really need linearizability, and what it costs. Linearizable vs serializable, quorum reads that still go stale, CAP and PACELC, and…
More on Ticket interviews
- Database Interviews in the AI Era: The Ticket Format
- Interview: the same job runs twice
- Deadlock Interview Question: Find and Fix It in SQL
- Slow Query Interview: One Keyword Made It 40× Slower
- Interview: rate limit is 2/min, 30 requests get through
- Interview: “just add an index” slowed ingestion
- Interview: “I changed my name, refresh shows the old one”
- Interview: importing 10M rows takes six hours
- Interview: everything got slow and the disk keeps growing
- Lost Update Interview: Wallet Balance Wrong Under Load
- Interview: API p99 jumps 10× every night at 2 am
- Interview: profile lookups got 40× slower, writes are fine
- Interview: inserts stall, and only one page is hot
- Interview: the write succeeded, the next read shows an empty cart
- Interview: inventory stayed locked after the coordinator restarted
- Interview: for four minutes, both regions took orders
- Interview: shoes show a 0% discount, then the report crashes
- Interview: March gained $50 after the deploy, and the months don’t add up
- Interview: the new branch’s dashboard takes 38 seconds
- Interview: the index is right there, make Postgres use it
- Interview: warehouse and checkout overwrite the same order
- Interview: the bestsellers report now takes nine minutes
- Interview: an analyst query locked checkout
- Interview: the member is active and the email went out twice
- Interview: one shard is at 96% CPU and the other is idle
- Interview: the menu is slow, and the proposal is event sourcing
- Interview: four dashboards disagree about whether the database is slow
- Interview: checkout got slow the hour the warehouse job started
- Interview: the query is fast in staging and slow in production
- Interview: login looks up an email and reads the whole customers table
- Interview: the proposal splits one database into three shards
- Interview: the order page joins four tables on every view
- Interview: every page view is a read-write query on the leader
- Interview: Sarah and John both debit version 1
- Interview: the CTO read a blog post and wants to move Postgres to MySQL
- Interview: one table takes 50,000 writes a second, another feeds dashboards. Which engine for each?
- Interview: EU users wait on the ocean for every write, can both regions take writes?
- Interview: users search cars by color, but the table is sharded by car id
- Interview: we added a fourth node and most of the data moved
- Interview: two people book the same room at noon, both get a confirmation
- Interview: the order is saved, the message to search and email never left
- Interview: rename a column on a 600 GB table while 30 servers keep serving traffic
- Interview: orders go to 16 shards in 2 regions, what should the order id be?
- Interview: one celebrity posts, and every timeline in the app slows down
- Interview: 5,000 customers share one database, and one of them slows down everyone
Keep learning
Overview
Strongest consistency everywhere made far requests slow and EU fragile. Which features really need it? Explain linearizability to a friend in four sentences. explain simply Many copies behave like one copy whose value changes at one moment. A read that starts after a write finishes must see it, or newer. A read overlapping the write may see old or new. Once anyone sees the new value, nobody may see the old one again. recency, not just agreement overlap can go either way no going back in time Is linearizable the same as serializable? what breaks if Serializable allows stale reads. Linearizable alone doesn’t stop write skew across several objects. Both together is strict serializability (Spanner, FoundationDB). one object versus many recency versus order both can be combined One object. Every read sees the latest finished write. We use quorums, so w + r > n. Our reads are linearizable, right? Not guaranteed: with a write in flight, a later reader can still see old. Last-write-wins on wall clocks (Cassandra) is almost surely not linearizable. Compare-and-set needs consensus. Assume leaderless is not linearizable. has a counterexample knows the repair costs latency CAS needs consensus read r1, r2 gets 1 read r2, r3 gets 0 — older! What does linearizability cost? Give numbers. Latency on every request, not just during partitions. Proven bound: response time grows with network-delay uncertainty. Even CPU memory isn’t linearizable by default, for speed. cost is constant, not rare uses a number A user sets their account to private, then uploads a photo from their phone. A stranger sees the photo. Only linearizable fixes it? what would you do instead No. It’s the simplest fix, but a targeted one is cheaper. Two channels raced: the privacy write and the upload message. Or send just that read to the leader. Don’t flip a global switch. spots the second channel cheaper targeted fixes avoids global switch Write: private version 42 Message carries v42 Reader waits for ≥ v42 Photo hidden Staff: product says “never show an error during a network cut”. CAP says pick two. Walk me through it. Daily cost is latency (PACELC). Partitions caused under 8% of Google incidents. not “pick two” decides per feature mentions latency when healthy Claim a username Show an error in a cut. Like a post Keep going, merge later. What it is Where I need it Unique names, locks, stock, balances, channel races. Where I do not Profiles: read-your-writes. Chat: causal. Likes: eventual. What it costs Strong for few keys, weaker elsewhere, a link-cut test. “CAP: pick any two” Partitions aren’t optional. Latency is paid even when healthy. “Quorum means linearizable” Two readers can disagree. Fixing it adds a repair per read. Strongest setting everywhere Likes and feeds pay a delay they never needed. Trusting every coordination-service read ZooKeeper reads may be stale. etcd v3 reads are linearizable by default. Recency guarantee on one object Needed for uniqueness, locks, limits, channel races Level per feature, not one switch Client C writes x equals 1 over a long bar. Client A reads 0 before the write, then reads 1 during the write. Client B starts a read after A got 1 and must also read 1. C writes A reads B reads reads 0 reads 1 must read 1 once A saw 1, nobody sees 0 again The write is not finished, yet B may not go back to 0. Eventual: nearest copy Session: a copy with your write Linearizable: leader across the ocean Illustrative latency bars: eventual about 5 ms, session about 7 ms, linearizable with a far leader about 150 ms. Illustrative numbers. The far trip is the cost, and it is paid on every such request. Session / causal A hard uniqueness rule. Claiming a name works like taking a lock. Two people get the same name. Elect the leader (lease or lock) Two holders at once is split brain. Two nodes both believe they lead. Take the last seat on a flight A hard stock limit needs one up-to-date value. If you can compensate for overbooking, you could relax this. The seat is sold twice. Video upload, then a transcode job reads it Two channels race. Linearizable storage is the simplest fix. Passing the version in the message also works. The job reads an old or missing file. Show my own profile after I edit it Only you must see your own write. Read-your-writes is enough. You edit, refresh, and see the old name. Show a reply after its question Cause must come before effect. That is causal order, not global recency. A reply appears before the question. Like counter on a post A few seconds stale is harmless, and counters can be merged. Live score or news page An outdated page by a few seconds rarely does harm. Give each feature the weakest guarantee that still works. All strongest Show the answer Works, but you pay for more than this needs. Features that break Paying for too much Features on the slow, strict path What to notice. Only four of the eight features need the strictest setting. The other four were paying the far trip for nothing. Read any replica Fast and spread out. Bryce can hit a replica that has not caught up. Read the leader Correct, but every read goes to one node. Far users cross the ocean, and a slow leader slows everyone. w + r > n holds, yet the write is still in flight. A saw the new value, B’s pair holds only old ones. Quorum + repair first A’s read copies the new value to replica 2 before answering. Now B’s pair includes it. Every read pays an extra write. How reads are served Aaliyah (first) reads Bryce (after her) reads replicas Aaliyah asked (solid ring) replicas Bryce asked (dashed ring) Linearizable here. Not linearizable. Bryce read after Aaliyah and got an older value. What to notice. The quorum row looks safe on paper and still fails. The repair row fixes it by making reads more expensive. Left: two cashiers share one seating chart, so the last seat is sold once. Right: three notice boards show the football score, and they can differ for a while. ONE SEATING CHART last seat: both must ask the same chart slower, but the seat is sold once NOTICE BOARDS OUTSIDE one board is a minute behind harmless, and very fast
Everything is on the strongest consistency, and far requests crawl. Where do we really need it?
Every table got the strictest consistency (acts like one copy). Far calls crawl, and a link cut failed EU. CAP and PACELC quorum is not enough cost of coordination Strictest consistency on every table, even harmless ones
The seating chart and the notice board
Seating chart One shared chart, or the last seat sells twice. Slower, but safe. Score boards One board a minute behind hurts nobody. Fast to read. The skill is telling these two apart.
Strongest consistency everywhere. Far requests are slow, and EU failed in a link problem.
Every table moved to the strictest consistency setting. Cross-region calls got slower. In a link cut, EU errored on every feature, even likes. far request EU in a cut all errors
Four places to sit on the consistency ladder
No stale reads Fast far away Works in a cut Hard rules hold Linearizable everywhere Linearizable where needed Causal + session Eventual + merge (CRDTs) Four places on the consistency ladder Small, must-be-right data: locks, config, balances. pick when Where needed Most real apps. Profiles, chat, feeds, comments. Eventual + merge Likes, views, carts, shared text. Flight booking, chat and like counts, in two regions. How do you place consistency? Everything linearizable Simple and never stale. Chat and likes pay the far trip and fail in a cut. Correct on hard rules Speed far away Mixed: linearizable for seats, causal for chat, eventual for likes Everything eventual, retry on errors Fast and always on. Two people can book the same seat.
Say these out loud first
Related chapters: quorum, split brain, serializability, version conflict.
A model answer
Where in your system do you really need linearizability?
More courses
- Jobs, linked to lessons — Browse jobs where every requirement links to the chapter that teaches it. See how ready you are, how long the gap takes to close, and which listings look stale.
- Match a job post to courses — Paste a job post. Each skill is matched to a track here and put in learning order, foundations first.
- React patterns from open source — Patterns extracted from Material UI, Radix, React Aria, React Hook Form, Redux Toolkit, TanStack, and Next.js — not slides about hooks.
- System Design — Core concepts first (SQL vs NoSQL, CAP, indexing, replication, sharding), then designs grouped by what carries them: the database, Redis, Kafka, or many services.
- NestJS: build a real API — One ticket-booking API, built in order: a plain Node server first, then NestJS modules, validation, a real database, and the features real clients lean on.
- Microservices — Microservice patterns one diagram at a time: how to split a monolith, how services talk, and how data stays consistent without distributed transactions.
- Kafka — A beginner-to-senior path through event logs, reliable delivery, production operations, and disaster recovery.
- AI engineering for software engineers — Eight free reads, in order, for software engineers moving into AI: when to build an agent, how to build one, how to test it, and how the model works underneath.
- Frontend system design — How a UI is sliced when it is a product, not a page: ownership of state, cache, routes, and what happens when the network lies.
- TypeScript in depth — The type system as a design tool. Inference, narrowing, generics, and the errors that mean the model is wrong — not a catalog of utility types.
- CSS in depth — See the box, then the page. Visual chapters from the box model through Flexbox surprises, Grid, selectors, and units, then backgrounds, shapes, and visual effects, each with a playground.
- Accessibility — Foundations first (WCAG in plain words, semantic HTML, lists, alt text), then hands-on HTML labs, a full pass of WAI-ARIA 1.3, and a final fix-the-page challenge.
- Docker — What an image is, why layers cache, and how containers find each other on a network.
- Redis — Fifteen Redis patterns, one picture each: cache, session, lock, counter, rate limiter, queue, and when Redis is the wrong tool.
- Kubernetes — Kubernetes from zero to operators: why it exists, Pods, Deployments and Services, then configuration, networking, storage, scheduling, scaling and security.
- AWS — AWS networking in plain English. A VPC is a gated housing society: streets are subnets, the Internet Gateway is the main gate, and a route table is the signboard.
- Networking: the NetRoute game — NetRoute is a packet logistics game. You wire up computers, switches, routers, firewalls and gateways, set each device, and watch glowing packets travel. If a packet gets dropped, the game shows you which header field was wrong.