#separator:tab
#html:true
#columns:Front	Back	Tags	GUID
#tags column:3
#guid column:4
#notetype:Basic
#deck:System Design Map
"Performance problem or scalability problem: how do you tell them apart?"	"<p>A <strong>performance</strong> problem shows up with one user: every request is slow, even on an idle system. Fix it with profiling, indexes and better algorithms.</p><p>A <strong>scalability</strong> problem shows up under load: one user is fine, ten thousand are not. Fix it by adding capacity, removing the shared bottleneck, caching or partitioning.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/performance-vs-scalability/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-perf-vs-scale"
"Scale up or scale out: what does each buy and cost?"	"<p><strong>Scale up</strong> (a bigger machine): no code changes and simple operations, but a hard ceiling, a steep price at the top and a single point of failure.</p><p><strong>Scale out</strong> (more machines): near-linear capacity and redundancy, but only for stateless tiers or data you can partition.</p><p>Default: scale up while it is cheap, and design for scale-out where you know you will need it.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/performance-vs-scalability/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-scale-up-out"
"What does Amdahl's law say about adding workers?"	"<p>With a parallel fraction <code>p</code> on <code>N</code> workers, the speed-up is <code>1 / ((1 − p) + p / N)</code>, and it can never exceed <code>1 / (1 − p)</code>. At 95% parallel the limit is 20×, at 99% it is 100×.</p><p>In a web system the serial part is whatever every request passes through one at a time: a single primary, a global lock, a hot row.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/performance-vs-scalability/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-amdahl"
"Why report latency as percentiles rather than an average?"	"<p>Latency is skewed, so the mean describes no real request. In the page's example of 1,000 requests, the mean is 38.9 ms, while p50 is 20 ms and p99 is 400 ms.</p><p>Set targets on p99 or p99.9, and never average percentiles across servers: merge histograms and compute the percentile from the merged data.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/latency-vs-throughput/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-percentiles"
"1% of servers are slow at any moment. How often does a request that touches 100 servers hit at least one slow one?"	"<p><code>1 − 0.99^100 ≈ 63%</code>. The response is only as fast as the slowest shard, so at a fan-out of about 70 a backend's p99 becomes the frontend's median.</p><p>Mitigations: hedged requests, partial results, fewer hops, and a deadline for each hop.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/latency-vs-throughput/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-fanout-tail"
"State Little's law and size a thread pool with it."	"<p><code>L = λW</code>: requests in flight = arrival rate × time in system.</p><p>An API at 2,000 requests/s with 150 ms per request has 300 requests in flight. A pool of 200 threads therefore caps out at about 1,333 requests/s at that latency. The same arithmetic sizes connection pools and queues.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/latency-vs-throughput/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-little"
"What happens to latency as a server's utilisation approaches 100%?"	"<p>It explodes. In the single-queue model, mean response time is <code>W = S / (1 − ρ)</code>: 2× the service time at 50% busy, 10× at 90%, 100× at 99%.</p><p>Keep headroom for peaks and failover, bound every queue, and treat a rising p99 as an early warning.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/latency-vs-throughput/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-utilisation"
"What does the CAP theorem actually say?"	"<p>Only <strong>during a network partition</strong> must a replicated system choose, per operation: stay consistent (linearizable, so some requests fail or time out) or stay available (every non-failing node answers, possibly with stale data).</p><p>Partitions are not optional, so “pick 2 of 3” is misleading, and only a single-node system is truly “CA”.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/cap-theorem/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-cap"
"What does PACELC add to CAP?"	"<p>If <strong>P</strong>artitioned, choose <strong>A</strong>vailability or <strong>C</strong>onsistency; <strong>E</strong>lse, choose <strong>L</strong>atency or <strong>C</strong>onsistency. The “else” half is paid on every request, not only during failures.</p><p>Cassandra and the original Dynamo are PA/EL; Spanner, CockroachDB and etcd are PC/EC. Modern databases are consistent by default and offer stale reads on request.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/cap-theorem/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-pacelc"
"When does a quorum read see the latest write, and is that enough for linearizability?"	"<p>With <code>N</code> replicas, a write waits for <code>W</code> acks and a read asks <code>R</code> replicas. If <code>R + W &gt; N</code> (say N = 3, W = 2, R = 2), every read set overlaps every write set.</p><p>Overlap is not linearizability: concurrent writes, partially failed writes and sloppy quorums can still produce anomalies.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/cap-theorem/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-quorum"
"A user edits their profile, refreshes and sees the old version. Which guarantee is missing, and how do you provide it?"	"<p><strong>Read-your-writes.</strong> Options:</p><ul><li>read from the leader for a short window after the user writes;</li><li>pin the session to one replica (sticky routing);</li><li>return the write's log position (an LSN or version) and read only from a replica that has applied it.</li></ul><p><a href=""https://butyavk.github.io/system-design/fundamentals/consistency-patterns/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-read-your-writes"
"Linearizability vs serializability: what is the difference?"	"<p><strong>Linearizability</strong>: single-object operations appear atomic and in real-time order, as if there were one copy. You need it for “check then act”: locks, claiming a username.</p><p><strong>Serializability</strong>: transactions appear in <em>some</em> serial order, not necessarily the real-time one. <strong>Strict serializability</strong> (Spanner's external consistency) is both.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/consistency-patterns/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-linearizable"
"How do availabilities combine in series and in parallel?"	"<p><strong>In series</strong> (every part is needed) availabilities multiply: 99.99% × 99.95% × 99.95% ≈ 99.89%, worse than any single part.</p><p><strong>In parallel</strong> (any copy will do) failure probabilities multiply: two servers at 99.5% give <code>1 − 0.005² = 99.9975%</code>. That holds only if the copies fail independently.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/availability-patterns/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-series-parallel"
"RTO vs RPO, and what do hot, warm and cold standbys give you?"	"<p><strong>RTO</strong>: how long you may be down. <strong>RPO</strong>: how much recent data you may lose.</p><ul><li>Hot standby: seconds to a minute; zero RPO with synchronous replication; about 2× the cost.</li><li>Warm: minutes, because it must scale up; seconds of data.</li><li>Cold: hours; everything since the last backup.</li></ul><p><a href=""https://butyavk.github.io/system-design/fundamentals/availability-patterns/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-rto-rpo"
"What is an error budget, and what happens when it runs out?"	"<p>The budget is <code>1 − SLO</code>. A 99.9% SLO over 30 days allows 43.2 minutes of full outage, or 100,000 failed requests out of 100 million.</p><p>While budget remains, ship features and take risks. When it is spent, the error budget policy freezes risky releases until the service is back within its SLO.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/availability-patterns/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-error-budget"
"How many voting nodes does a consensus group need, and why use odd sizes?"	"<p>A decision needs a <strong>majority</strong>, so <code>2f + 1</code> nodes tolerate <code>f</code> failures: 3 survive 1, 5 survive 2, 7 is the practical ceiling.</p><p>Four nodes need 3 votes and still tolerate only one failure, so the fourth adds cost and latency, not resilience. To scale reads, add non-voting members (etcd learners, ZooKeeper observers); spread voters across zones.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/consensus-and-coordination/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-consensus-majority"
"How does Raft elect a leader and commit a log entry?"	"<p>Time is split into numbered <strong>terms</strong> with at most one leader each; a node that sees a higher term steps down, which makes a deposed leader harmless. A follower that hears no heartbeat for a randomised <strong>election timeout</strong> asks for votes; a majority makes it leader, and only candidates with an up-to-date log can win.</p><p>The leader appends commands and replicates them; an entry is <strong>committed</strong> once a majority has stored it.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/consensus-and-coordination/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-raft"
"A client holds a lease-based lock, pauses for a long GC, and the lease expires. How do you keep it from corrupting data?"	"<p>No lease can stop a paused client by itself, so the <strong>resource</strong> must protect itself. A <strong>fencing token</strong> grows with every lock grant (an etcd revision, a ZooKeeper zxid); the client sends it with each write, and storage rejects any token lower than the highest it has seen.</p><p>Or use conditional writes. A Redis lock without fencing is fine for efficiency, not for correctness.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/consensus-and-coordination/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-fencing"
"What does a consensus commit cost, and when should you avoid running consensus yourself?"	"<p>About one round trip to the nearest follower plus an <code>fsync</code>: ≈ 1.2 ms in one zone, ≈ 2 ms across three zones, ≈ 81 ms with followers across an ocean.</p><p>Don't implement Raft or Paxos. Prefer, in order: your database (unique constraint, transaction, conditional write), your platform (Kubernetes Leases), a coordination service with 3 or 5 voters. Many “exactly once” problems need idempotency, not a lock.</p><p><a href=""https://butyavk.github.io/system-design/fundamentals/consensus-and-coordination/"">Read more on the site</a></p>"	"system-design sdp::fundamentals"	"sdp-en-fund-consensus-cost"
"Walk through a DNS lookup from the browser to the answer."	"<p>The OS <strong>stub resolver</strong> asks a <strong>recursive resolver</strong>, which follows referrals from a <strong>root</strong> server to the <strong>TLD</strong> server to the <strong>authoritative</strong> server for the zone.</p><p>Root and TLD referrals carry long TTLs, so a warm resolver usually goes straight to the authoritative server, and caches at every layer make most lookups a single local hop.</p><p><a href=""https://butyavk.github.io/system-design/traffic/dns/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-dns-lookup"
"How do you pick a DNS TTL, and how do you prepare a migration?"	"<p>Short TTLs (30–60 s) move traffic quickly but raise query volume and cache misses; long TTLs (hours) are cheap but slow to change.</p><p>Before a migration: lower the TTL, wait at least one <em>old</em> TTL, switch, then raise it again. Some clients ignore TTLs, so don't plan on DNS failover faster than about a minute.</p><p><a href=""https://butyavk.github.io/system-design/traffic/dns/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-dns-ttl"
"GeoDNS vs anycast: how does each steer users, and how fast does it react to a failure?"	"<p><strong>GeoDNS</strong> returns different answers per resolver location: fine-grained control, but it sees the resolver rather than the user and reacts only after a TTL and client caches.</p><p><strong>Anycast</strong> announces one IP from many sites over BGP: failover in seconds to a minute, and attack traffic spreads over all sites, but control is coarse. Large providers combine both.</p><p><a href=""https://butyavk.github.io/system-design/traffic/dns/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-geodns-anycast"
"Push CDN vs pull CDN: when do you use each?"	"<p><strong>Pull</strong>: the edge fetches from the origin on the first miss and keeps what users request. Suits busy sites, long-tail catalogues and APIs.</p><p><strong>Push</strong>: you upload content ahead of time. Suits large files with predictable demand (installers, game patches) and small sites that rarely change.</p><p>The common setup today is a pull CDN in front of object storage.</p><p><a href=""https://butyavk.github.io/system-design/traffic/cdn/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-cdn-push-pull"
"What is the best way to change content that a CDN has cached?"	"<p>Best: <strong>versioned URLs</strong>. Put a content hash in the file name (<code>app.3f9c2b.js</code>) and cache it forever; a deploy publishes new names, with no purge and no races.</p><p>Next best: tag-based purge, then URL or prefix purge. Purging everything is a last resort: every PoP misses at once and the origin takes a stampede.</p><p><a href=""https://butyavk.github.io/system-design/traffic/cdn/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-cdn-invalidation"
"What does an origin shield do, in numbers?"	"<p>It adds one upper-tier cache between the PoPs and the origin and collapses concurrent misses into a single origin fetch.</p><p>Without it, 300 PoPs with a 60-second TTL can send up to 5 requests per second for one popular object. With a shield it is one request per object per 60 seconds, at the cost of an extra hop on misses.</p><p><a href=""https://butyavk.github.io/system-design/traffic/cdn/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-origin-shield"
"Layer 4 vs layer 7 load balancing: what is the difference?"	"<p><strong>L4</strong> works on TCP/UDP flows: it picks a backend once per connection by IP and port, without reading the payload. Fast, cheap, any protocol.</p><p><strong>L7</strong> terminates the connection, parses HTTP or gRPC and picks a backend per request: routing by path, header or cookie, TLS, retries, per-request metrics.</p><p>Gotcha: under L4, long-lived HTTP/2 or gRPC connections pin a client's load to one backend.</p><p><a href=""https://butyavk.github.io/system-design/traffic/load-balancers/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-l4-l7"
"Some requests take 10 ms and others 2 s. Which balancing algorithm do you choose?"	"<p><strong>Least outstanding requests</strong>, or <strong>power of two choices</strong>: pick two servers at random and send to the less loaded one. P2C removes most of the imbalance of pure random choice and suits many independent balancers or sidecars.</p><p>Round robin only fits uniform requests. For key affinity use consistent hashing: growing from 10 to 11 servers moves about 9% of keys, versus about 91% with <code>hash mod N</code>.</p><p><a href=""https://butyavk.github.io/system-design/traffic/load-balancers/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-lb-algorithms"
"Sticky sessions or stateless app servers?"	"<p>Sticky sessions pin a user to the server holding their state: load becomes uneven, a crash loses those sessions, and scaling in waits for sessions to drain.</p><p>Default to <strong>stateless</strong> servers: keep sessions in a signed token or a shared store such as Redis or Valkey, and files in object storage. Use stickiness only as an optimisation that nothing depends on.</p><p><a href=""https://butyavk.github.io/system-design/traffic/load-balancers/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-sticky-sessions"
"What can go wrong with load balancer health checks?"	"<ul><li>A deep check that queries a shared database fails on every server when the database blips, and the balancer has nowhere to send traffic. Keep checks mostly local.</li><li>Detection is slow: with AWS ALB defaults (30-second interval, 2 failures) a dead server gets traffic for about a minute.</li><li>Know whether the balancer fails open when every check fails; drain connections on deploy and slow-start new instances.</li></ul><p><a href=""https://butyavk.github.io/system-design/traffic/load-balancers/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-health-checks"
"Reverse proxy, load balancer, API gateway: what does each do?"	"<ul><li><strong>Reverse proxy</strong>: one controlled front door for TLS, caching, compression, static files and filtering; useful even with a single backend.</li><li><strong>Load balancer</strong>: a reverse proxy whose main job is spreading load across identical servers and surviving their failures.</li><li><strong>API gateway</strong>: cross-cutting API concerns for many services: authentication, quotas, routing, versioning. Keep business logic out of it.</li></ul><p><a href=""https://butyavk.github.io/system-design/traffic/reverse-proxy-and-api-gateway/"">Read more on the site</a></p>"	"system-design sdp::traffic"	"sdp-en-traffic-proxy-gateway"
"What is a modular monolith, and why is it the default?"	"<p>One deployable whose modules have explicit public interfaces, enforced dependency rules and their own tables.</p><p>It keeps one build, one deploy and in-process calls, while getting most of the design benefits of services. Its seams also make it the easiest system to split later. Shopify is the best-known example.</p><p><a href=""https://butyavk.github.io/system-design/architecture/monolith-and-microservices/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-modular-monolith"
"When do microservices pay off, and what do they cost?"	"<p>They pay off for mostly organisational reasons: many teams that need to deploy independently, very different scaling profiles, fault or security isolation.</p><p>Costs: network calls instead of function calls, partial failure, no cross-service transactions or joins, and heavy platform work. Ten services in sequence at 99.9% each succeed only about 99.0% of the time. The worst outcome is a distributed monolith.</p><p><a href=""https://butyavk.github.io/system-design/architecture/monolith-and-microservices/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-microservices-when"
"How do you migrate away from a legacy system without a big-bang rewrite?"	"<p>The <strong>strangler fig</strong> pattern:</p><ol><li>Put a routing layer (reverse proxy or API gateway) in front of the legacy system.</li><li>Rebuild one capability with a clear seam and shift its traffic gradually.</li><li>Keep data in sync with CDC or an outbox during the move.</li><li>Delete the old code path, then repeat.</li></ol><p><a href=""https://butyavk.github.io/system-design/architecture/monolith-and-microservices/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-strangler-fig"
"Client-side vs server-side service discovery?"	"<p><strong>Client-side</strong>: the caller queries the registry, caches the list and balances itself. No extra hop and smart per-request balancing, but every language needs a library.</p><p><strong>Server-side</strong>: the caller hits a load balancer or virtual IP that does the lookup. Simple clients, but an extra component, and an L4 VIP pins long-lived gRPC connections.</p><p>On Kubernetes, Services, EndpointSlices and cluster DNS provide discovery out of the box.</p><p><a href=""https://butyavk.github.io/system-design/architecture/service-discovery-and-mesh/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-discovery"
"What does a service mesh give you, and when is it overkill?"	"<p>Without code changes: mTLS with workload identities, timeouts, retries with budgets, traffic splitting for canaries, and uniform per-service metrics. Data planes are sidecars, sidecar-less “ambient” mode, eBPF or proxyless gRPC.</p><p>It is overkill with a few services owned by one team, or when nobody can own the control plane. Start from a concrete need such as “we need mTLS”.</p><p><a href=""https://butyavk.github.io/system-design/architecture/service-discovery-and-mesh/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-mesh"
"How do you reason about latency for an LLM response, and why stream it?"	"<p>End-to-end ≈ <code>TTFT + TPOT × (output tokens − 1)</code>. Time to first token covers queueing, retrieval and prefill (grows with prompt length); time per output token is a decode step (memory-bandwidth-bound).</p><p>With 0.5 s TTFT, 20 ms per token and 300 tokens, the answer takes about 6.5 s, but streaming over SSE shows text after half a second. Don't buffer on the path, and cancel generation when the client leaves.</p><p><a href=""https://butyavk.github.io/system-design/architecture/llm-applications/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-llm-latency"
"Why budget, price and rate-limit an LLM feature in tokens rather than requests?"	"<p>One request can cost a hundred times another. In the page's example (5 M requests a day, 2,000-token prompts, 300-token answers) input is 57% of a $17,500/day bill even though input tokens are five times cheaper; caching a repeated 60% prefix cuts the total by about 31%.</p><p>So use token buckets charged in tokens, concurrency limits on open streams and per-tenant budgets.</p><p><a href=""https://butyavk.github.io/system-design/architecture/llm-applications/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-llm-tokens"
"RAG over company documents: what are the hard parts?"	"<ul><li><strong>Chunking</strong> into passages of a few hundred tokens, keeping titles and section paths.</li><li><strong>Hybrid search</strong>: vectors plus BM25 for exact terms, then a <strong>reranker</strong> over a broad candidate set.</li><li><strong>Freshness</strong>: the index is derived data fed by change events; deletions must apply fast.</li><li><strong>Permissions</strong>: store ACLs with each chunk and filter at retrieval time — never ask the model to hide what the user may not see.</li></ul><p><a href=""https://butyavk.github.io/system-design/architecture/llm-applications/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-llm-rag"
"How do resilience patterns change when the dependency is an LLM?"	"<ul><li>Separate timeouts for the first token, idle gaps between tokens and the whole call.</li><li><strong>Retry before the stream starts, not during it</strong>: a mid-stream retry produces a different second half.</li><li>Fall back to another model behind a model gateway, with a circuit breaker per provider, and run the fallback through the same evals.</li><li>Validate structured output; give each tool call an idempotency key.</li><li>Treat output as untrusted input: no prompt-level defence fully stops prompt injection.</li></ul><p><a href=""https://butyavk.github.io/system-design/architecture/llm-applications/"">Read more on the site</a></p>"	"system-design sdp::architecture"	"sdp-en-arch-llm-reliability"
"Define each letter of ACID precisely."	"<ul><li><strong>Atomicity</strong>: all of a transaction's writes take effect, or none do.</li><li><strong>Consistency</strong>: each transaction keeps declared invariants; mostly your job, and not the C in CAP.</li><li><strong>Isolation</strong>: concurrent transactions don't see each other's partial work, to a chosen level.</li><li><strong>Durability</strong>: once <code>COMMIT</code> returns, the change survives a crash, because the WAL is flushed first.</li></ul><p><a href=""https://butyavk.github.io/system-design/data/relational-databases/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-acid"
"What are the default isolation levels of PostgreSQL and MySQL, and do they prevent write skew?"	"<p>PostgreSQL: <strong>read committed</strong>. MySQL InnoDB: <strong>repeatable read</strong>. Neither prevents write skew.</p><p>Write skew: two transactions read the same data and write <em>different</em> rows, breaking an invariant together (both on-call doctors go off duty). Fix it with <code>SELECT … FOR UPDATE</code>, a constraint, or serializable isolation plus retries.</p><p><a href=""https://butyavk.github.io/system-design/data/relational-databases/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-isolation-defaults"
"What is MVCC, and what is its operational catch?"	"<p>Multi-version concurrency control keeps several versions of each row; a reader sees the newest version committed before its snapshot, so readers and writers don't block each other.</p><p>Catch: old versions must be cleaned up (<code>VACUUM</code> in PostgreSQL, purge of the undo log in InnoDB). A transaction left open for hours pins them, bloating tables or the undo history.</p><p><a href=""https://butyavk.github.io/system-design/data/relational-databases/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-mvcc"
"B-tree vs LSM-tree: which workloads does each favour?"	"<p><strong>B-tree</strong> (PostgreSQL, InnoDB): change pages in place, predictable point reads and range scans. Read-heavy OLTP.</p><p><strong>LSM-tree</strong> (RocksDB, Cassandra, CockroachDB): append to a log and memory buffer, flush sorted files and compact later. High write throughput; reads may check several files, with Bloom filters skipping most. Write-heavy ingestion.</p><p><a href=""https://butyavk.github.io/system-design/data/relational-databases/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-btree-lsm"
"In what order do you scale a relational database?"	"<ol><li>Tune queries, indexes and schema (often 10× to 1000× for one query).</li><li>Scale up.</li><li>Pool connections and cache.</li><li>Add read replicas.</li><li>Federate or shard.</li></ol><p>Each step costs more complexity than the last, so climb only when measurements show the current step is exhausted.</p><p><a href=""https://butyavk.github.io/system-design/data/relational-databases/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-scaling-ladder"
"Synchronous, asynchronous or semi-synchronous replication: what do you trade?"	"<ul><li><strong>Async</strong>: no commit latency, but failover can lose the last transactions.</li><li><strong>Sync</strong>: no loss if a sync replica is promoted, but every commit waits a round trip, and writes stall if the replica is unreachable.</li><li><strong>Semi-sync / quorum</strong>: wait for the fastest <em>k</em> replicas.</li></ul><p>Watch out: MySQL semi-sync silently falls back to async after a 10-second timeout.</p><p><a href=""https://butyavk.github.io/system-design/data/replication/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-sync-async"
"What is split brain, and how do you prevent it?"	"<p>Two nodes both believe they are the leader and both accept writes, so the data diverges and merging is manual.</p><p>Defences: a <strong>majority quorum</strong> for leader election, <strong>fencing tokens</strong> (a higher epoch per leader, and storage rejects older ones), and <strong>STONITH</strong>. GitHub's 43-second partition in 2018 left the site degraded for 24 hours and 11 minutes.</p><p><a href=""https://butyavk.github.io/system-design/data/replication/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-split-brain"
"Multi-leader replication: how are write conflicts resolved?"	"<p>From crude to careful:</p><ul><li><strong>Avoid</strong> them: route each record's writes to one home leader (the most effective).</li><li><strong>Last-writer-wins</strong>: simple, but silently drops writes and lets clock skew pick the winner.</li><li><strong>Merge</strong> siblings tracked by version vectors.</li><li><strong>CRDTs</strong>, which always converge.</li><li><strong>Detect and abort</strong>, as MySQL Group Replication does.</li></ul><p><a href=""https://butyavk.github.io/system-design/data/replication/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-multi-leader"
"Can read replicas fix a write bottleneck? Are replicas backups?"	"<p>No to both. Every replica applies every write, so replicas add read capacity, never write capacity; for writes you need partitioning.</p><p>A bad migration or <code>DROP TABLE</code> replicates within milliseconds, so keep point-in-time backups and delayed replicas as well.</p><p><a href=""https://butyavk.github.io/system-design/data/replication/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-replicas-writes"
"Federation vs sharding?"	"<p><strong>Federation</strong> splits by function: users, orders and catalogue each get their own database. It matches service ownership, but there are no cross-database joins or transactions, and it stops helping once one domain outgrows a server.</p><p><strong>Sharding</strong> splits one dataset by key across servers, so it scales writes and data size within a domain.</p><p><a href=""https://butyavk.github.io/system-design/data/partitioning-and-sharding/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-federation-sharding"
"What makes a good shard key?"	"<ul><li><strong>High cardinality</strong>: millions of distinct values.</li><li><strong>Even spread</strong> of both data and traffic.</li><li><strong>Matches the dominant queries</strong>, so they stay on one shard (<code>tenant_id</code> for B2B SaaS, <code>user_id</code> for consumer apps).</li><li><strong>Stable</strong>: changing it means moving the row.</li></ul><p>Avoid a raw timestamp: in a range-sharded cluster all new writes land on the last shard.</p><p><a href=""https://butyavk.github.io/system-design/data/partitioning-and-sharding/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-shard-key"
"Hash, range and directory sharding: the strength and weakness of each?"	"<ul><li><strong>Hash</strong>: even spread even with sequential keys, but range queries hit every shard.</li><li><strong>Range</strong>: efficient range scans and easy splits, but sequential keys create a hot last shard.</li><li><strong>Directory</strong>: any placement and per-tenant moves, but the lookup service must be fast, cached and highly available.</li></ul><p>A common hybrid: hash into many logical shards and map them to servers with a small directory.</p><p><a href=""https://butyavk.github.io/system-design/data/partitioning-and-sharding/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-hash-range-dir"
"Why consistent hashing instead of <code>hash % N</code>, and why virtual nodes?"	"<p>With <code>hash % N</code>, going from 4 to 5 servers moves about 80% of keys. On a ring, a key belongs to the first server clockwise, so a joining node takes only about 1/(N+1) of the keys (20% going from 4 to 5).</p><p><strong>Virtual nodes</strong> (many ring positions per server; Cassandra uses 16 tokens per node by default) even out the arcs, let bigger machines take more, and spread a failed server's load over all survivors.</p><p><a href=""https://butyavk.github.io/system-design/data/partitioning-and-sharding/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-consistent-hashing"
"One celebrity key overloads its shard. What are your options?"	"<ul><li><strong>Split the key</strong>: append a suffix 0–9 so writes spread over ten shards (50,000 writes/s becomes about 5,000 per shard); reads gather all ten.</li><li><strong>Cache it</strong>: most celebrity traffic is reads.</li><li><strong>Give it its own shard</strong> through a directory.</li><li><strong>Handle it on read</strong>, as timelines do for celebrity posts.</li></ul><p>Automatic splitting cannot divide a single row's traffic.</p><p><a href=""https://butyavk.github.io/system-design/data/partitioning-and-sharding/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-hot-key"
"What do queries without the shard key cost, and how do you handle cross-shard transactions?"	"<p>They become <strong>scatter-gather</strong> across every shard, paced by the slowest: with a 1% chance of a slow shard, a 32-shard fan-out hits one 27.5% of the time. Add global secondary indexes, co-locate related tables by the same key, and copy small reference tables to every shard.</p><p>Two-phase commit blocks if the coordinator fails, so keep invariants within one shard and use sagas for workflows.</p><p><a href=""https://butyavk.github.io/system-design/data/partitioning-and-sharding/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-cross-shard"
"When does denormalisation pay off, and what must you decide?"	"<p>When reads vastly outnumber writes and joins are the bottleneck. A join costing 2 ms at 10,000 reads/s burns 20 s of database time per second; keeping a copy at 1 ms × 100 writes/s costs 0.1 s.</p><p>Decide who keeps the copies in sync (same transaction, trigger, materialized view or CDC) and run a reconciliation job to catch drift.</p><p><a href=""https://butyavk.github.io/system-design/data/denormalization-and-tuning/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-denormalize"
"How do you design a composite index for a query?"	"<p>Equality columns first, then the range or sort column: <code>(customer_id, created_at)</code> serves <code>WHERE customer_id = ? ORDER BY created_at</code>. Make it covering if possible. In the page's example the plan dropped from about 17,000 pages and 143 ms to 7 pages and under 0.1 ms.</p><p>Indexes don't help unselective filters (a status matching a quarter of the table), and every index slows writes.</p><p><a href=""https://butyavk.github.io/system-design/data/denormalization-and-tuning/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-composite-index"
"What are N+1 queries and OFFSET pagination costing you?"	"<p><strong>N+1</strong>: 50 posts then each author is 51 queries, about 25 ms of round trips at 0.5 ms each; eager loading or a join makes it two (about 1 ms).</p><p><strong>OFFSET</strong>: <code>OFFSET 1000000</code> reads and discards a million rows, and pages shift on inserts. <strong>Keyset</strong> pagination (<code>WHERE (created_at, id) &lt; ($1, $2)</code>) served page 50,001 in 0.18 ms instead of 226 ms.</p><p><a href=""https://butyavk.github.io/system-design/data/denormalization-and-tuning/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-n1-keyset"
"Why put a connection pooler in front of PostgreSQL, and what does transaction mode break?"	"<p>PostgreSQL runs one OS process per connection, so thousands of mostly idle connections from autoscaled app servers waste memory and throughput. PgBouncer multiplexes them onto a few dozen server connections, sized near the core count times a small factor.</p><p>Transaction mode, the usual choice, breaks session state: <code>SET</code>, <code>LISTEN</code>, session advisory locks and <code>WITH HOLD</code> cursors.</p><p><a href=""https://butyavk.github.io/system-design/data/denormalization-and-tuning/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-pooling"
"Name the four classic NoSQL families and what each is good at."	"<ul><li><strong>Key-value</strong> (Redis, DynamoDB): lookups by key at extreme throughput.</li><li><strong>Document</strong> (MongoDB, Firestore): whole aggregates read in one go, flexible fields.</li><li><strong>Wide-column</strong> (Cassandra, Bigtable): write-heavy, time-ordered data at scale.</li><li><strong>Graph</strong> (Neo4j, Neptune): multi-hop traversals.</li></ul><p>Three more matter in 2026: time-series, search engines and vector stores.</p><p><a href=""https://butyavk.github.io/system-design/data/nosql/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-nosql-families"
"How does NoSQL data modelling differ from relational modelling?"	"<p>Relational modelling starts from entities; NoSQL starts from <strong>queries</strong>.</p><ol><li>List every access pattern with its rate and latency target.</li><li>Choose partition and sort keys so each pattern reads one partition.</li><li>Denormalise the fields each query needs.</li><li>Add secondary indexes for the rest.</li><li>Check for hot partitions (DynamoDB: 3,000 read and 1,000 write units per second per partition).</li></ol><p><a href=""https://butyavk.github.io/system-design/data/nosql/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-access-patterns"
"SQL or NoSQL for a new product?"	"<p>Start relational (usually PostgreSQL) unless a clear requirement rules it out: writes beyond one primary, single-digit-ms latency at huge scale, or a data model it handles badly. If you cannot list the queries yet, you need SQL's flexibility.</p><p>Choose NoSQL for a specific workload with known access patterns. Keep one system of record per piece of data; treat every other copy as a rebuildable cache or index.</p><p><a href=""https://butyavk.github.io/system-design/data/sql-or-nosql/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-sql-or-nosql"
"What does distributed SQL (Spanner, CockroachDB, YugabyteDB) give you, and at what price?"	"<p>SQL and ACID transactions with horizontal write scaling, automatic rebalancing and survival of node or zone failures without manual failover.</p><p>Price: every commit needs a consensus round trip, so writes take a few ms within a region and tens to hundreds across regions; cross-range transactions cost more; some features are missing; hot rows still serialise.</p><p><a href=""https://butyavk.github.io/system-design/data/sql-or-nosql/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-distributed-sql"
"What is the standard storage pattern for user uploads?"	"<p><strong>Metadata in a database, bytes in object storage, a CDN in front.</strong> Clients upload and download directly with short-lived presigned URLs, so app servers never proxy bytes.</p><p>Give each version a new key so CDN caches never need purging, validate uploads asynchronously, and reconcile orphans between the two stores.</p><p><a href=""https://butyavk.github.io/system-design/data/object-storage/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-object-storage"
"Durability vs availability for object storage such as S3 Standard?"	"<p><strong>Durability</strong> (will the data survive?) is designed at 11 nines: store 10 million objects and expect to lose one about once every 10,000 years. <strong>Availability</strong> (can I read it now?) is 99.99%, about 53 minutes of errors a year.</p><p>The bigger durability risk is people and software, so use versioning, object lock and cross-account replication. S3 has been strongly consistent since December 2020.</p><p><a href=""https://butyavk.github.io/system-design/data/object-storage/"">Read more on the site</a></p>"	"system-design sdp::data"	"sdp-en-data-durability-availability"
"Why does caching work, and what makes a cache “load-bearing”?"	"<p>Access is <strong>skewed</strong>: with a Zipf exponent of 1 over a million items, the top 1% get about 68% of requests. Recently used data is also likely to be used again.</p><p>At a 95% hit ratio the database sees 5% of reads; if the cache is flushed or restarted, it suddenly gets 20× its usual load. Plan for that cold-cache case.</p><p><a href=""https://butyavk.github.io/system-design/caching/caching-layers/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-why"
"How does hit ratio translate into latency and database load?"	"<p>Effective latency = <code>h·t_cache + (1−h)·t_origin</code>. With Redis at 0.5 ms, a 20 ms query and 50,000 reads/s:</p><ul><li>90% hits: 2.5 ms, 5,000 reads/s reach the database;</li><li>99% hits: 0.7 ms, 500 reads/s.</li></ul><p>The last few percent matter most: 90% → 99% cuts database load tenfold.</p><p><a href=""https://butyavk.github.io/system-design/caching/caching-layers/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-hit-ratio"
"Why cache objects rather than query results?"	"<p>A query-level key is a hash of SQL and parameters; when one row changes you cannot tell which cached queries included it. That is why MySQL's query cache was removed in 8.0.</p><p>An object-level key comes from domain identity (<code>user:v1:42</code>), so a change maps to known keys to delete, and every reader of the object shares the entry.</p><p><a href=""https://butyavk.github.io/system-design/caching/caching-layers/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-object-vs-query"
"Describe cache-aside (lazy loading): the read path, the write path and the risks."	"<p>Read: check the cache; on a miss, load from the database and store it with a TTL. Write: update the database, then <strong>delete</strong> the key.</p><p>Only requested data is cached and the cache can fail without losing data. Costs: a miss takes three round trips, data is stale until TTL or delete, and slow first reads after a flush.</p><p><a href=""https://butyavk.github.io/system-design/caching/cache-strategies/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-aside"
"Write-through vs write-behind?"	"<p><strong>Write-through</strong>: write to the cache, which writes the database synchronously. Fresh after every write through that path, but each write pays both latencies, and writes that bypass the cache go stale.</p><p><strong>Write-behind</strong>: acknowledge after the cache write and flush to the database later, often batched. Very fast and coalesces updates, but data is lost if the cache fails before flushing. Never for payments without a durable log.</p><p><a href=""https://butyavk.github.io/system-design/caching/cache-strategies/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-write-strategies"
"On write, why delete the cache key instead of setting the new value, and in which order?"	"<p>Two writers that <strong>set</strong> values can reach the cache in a different order from their database commits and leave the older value cached. A <strong>delete</strong> is idempotent, so the order doesn't matter, and the next reader loads the latest value.</p><p>Commit first, then delete; deleting first lets a reader refill the old value. Keep a TTL as the backstop for the remaining race.</p><p><a href=""https://butyavk.github.io/system-design/caching/cache-strategies/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-delete-not-update"
"What is a cache stampede, and how do you prevent it?"	"<p>A hot key expires (or the cache restarts) and hundreds of concurrent misses hit the database with the same expensive query. Fixes:</p><ul><li>TTL jitter;</li><li>request coalescing (single-flight);</li><li>a short lock or lease: Facebook's leases cut the peak from 17,000 to 1,300 queries/s;</li><li>serve stale while one request revalidates;</li><li>probabilistic early expiration (XFetch).</li></ul><p><a href=""https://butyavk.github.io/system-design/caching/cache-strategies/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-stampede"
"Cache penetration and hot keys: what are they and how do you fix them?"	"<p><strong>Penetration</strong>: requests for keys that don't exist always miss and always reach the database. Fix with negative caching (cache “not found” briefly), a Bloom filter of valid IDs, and input validation.</p><p><strong>Hot keys</strong>: one key saturates its cache shard. Fix with a local L1 cache with a TTL of a second or two, or key replicas (<code>item:42#0</code> … <code>#7</code>), reading one at random.</p><p><a href=""https://butyavk.github.io/system-design/caching/cache-strategies/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-penetration-hotkeys"
"LRU, LFU or W-TinyLFU? And what is the Redis/Valkey default eviction policy?"	"<p><strong>LRU</strong> suits recency-driven workloads, but one scan flushes the hot set. <strong>LFU</strong> suits stable popularity but is slow to forget. <strong>W-TinyLFU</strong> (Caffeine) admits a newcomer only if a frequency sketch says it beats the victim, so it resists scans.</p><p>Redis and Valkey default to <code>noeviction</code>: writes fail when memory is full. For a cache set <code>maxmemory</code> and <code>allkeys-lru</code> or <code>allkeys-lfu</code>.</p><p><a href=""https://butyavk.github.io/system-design/caching/cache-strategies/"">Read more on the site</a></p>"	"system-design sdp::caching"	"sdp-en-cache-eviction"
"When should a step go through a queue, and when not?"	"<p>Use a queue for <strong>slow work</strong> (answer <code>202 Accepted</code> with a job ID), <strong>bursty load</strong> (absorb a 10× spike and process at a steady rate) and <strong>decoupling</strong> producers from consumers.</p><p>Don't when the user needs the answer now, the work is cheap, read-your-writes matters, or the system is small. A table with <code>SELECT … FOR UPDATE SKIP LOCKED</code> is a fine queue at modest volume.</p><p><a href=""https://butyavk.github.io/system-design/async/queues-and-back-pressure/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-why-queue"
"Why do message queues deliver duplicates, and how do you get effectively-once processing?"	"<p>Real brokers deliver <strong>at least once</strong>: a worker can commit and crash before the ack, a lease can expire mid-job, or a producer can resend after a timeout.</p><p>Effectively-once = at-least-once + an <strong>idempotent consumer</strong>: a natural upsert, or recording processed message IDs in the same transaction as the side effect. External calls need an idempotency key.</p><p><a href=""https://butyavk.github.io/system-design/async/queues-and-back-pressure/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-at-least-once"
"How should a consumer handle acks, retries and poison messages?"	"<ul><li><strong>Ack after commit</strong>, never before.</li><li>Set the visibility timeout above p99 processing time, extending it from a heartbeat for long jobs.</li><li>Retry transient errors with a delay; dead-letter malformed payloads at once.</li><li><strong>Cap attempts</strong> and move failures to a <strong>dead-letter queue</strong>; alert when it holds anything and keep a redrive tool.</li></ul><p><a href=""https://butyavk.github.io/system-design/async/queues-and-back-pressure/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-dlq"
"What is back pressure, and how do you apply it?"	"<p>Pushing overload back to the source instead of letting an unbounded queue turn it into minutes of latency and memory exhaustion.</p><ul><li>Bound every queue.</li><li>Reject at the edge: <code>429</code> for one client over quota, <code>503</code> when the service is saturated, both with <code>Retry-After</code>.</li><li>Shed low-value or expired work first.</li><li>Watch the age of the oldest message, not just depth.</li></ul><p>Clients retry with exponential backoff and full jitter.</p><p><a href=""https://butyavk.github.io/system-design/async/queues-and-back-pressure/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-back-pressure"
"Size a worker pool: 400 jobs/s, 0.5 s per job. And how long does a 10-minute backlog take to drain?"	"<p>In flight: 400 × 0.5 = 200. For 70% utilisation, 286 slots: 18 pods × 16 = 288 slots, maximum 576 jobs/s.</p><p>A 10-minute outage leaves 240,000 jobs. They drain at 576 − 400 = 176 jobs/s, about 23 minutes; 25 pods would take 10 minutes. Headroom decides how fast you recover.</p><p><a href=""https://butyavk.github.io/system-design/async/queues-and-back-pressure/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-little-workers"
"How does ordering work in a Kafka-style log, and how do you choose the partition key?"	"<p>Order exists <strong>per partition only</strong>. Pick the key by the invariant: if “payment captured” must follow “order placed”, both use the order ID.</p><p>Watch out: hot keys make hot partitions; adding partitions remaps keys and breaks per-key order during the change (so over-provision up front); and retries reorder unless the producer is idempotent.</p><p><a href=""https://butyavk.github.io/system-design/async/event-streaming/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-partitions-order"
"How do consumer groups and offsets work, and what is the key health metric?"	"<p>Each partition goes to at most one member of a group: 12 partitions and 4 members means 3 each, and a 13th member sits idle. Parallelism is capped by the partition count. Other groups read independently with their own offsets.</p><p>Commit after processing for at-least-once. Watch <strong>consumer lag</strong>, converted to time, and alert when it keeps growing.</p><p><a href=""https://butyavk.github.io/system-design/async/event-streaming/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-consumer-groups"
"What does “exactly-once” in Kafka really cover?"	"<p>A consume → transform → produce loop that stays <strong>inside Kafka</strong>, built from the idempotent producer, transactions that write outputs and commit offsets atomically, and <code>read_committed</code> consumers.</p><p>Once you write to Postgres, call an API or send an email, you are back to at-least-once plus idempotence, which is why “effectively-once” is the more honest name.</p><p><a href=""https://butyavk.github.io/system-design/async/event-streaming/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-exactly-once"
"A service must update its database and publish an event. How do you avoid a dual write?"	"<p><strong>Transactional outbox</strong>: insert the event into an <code>outbox</code> table in the same local transaction as the business change. A relay publishes it, usually via <strong>CDC</strong> that tails the replication log (Debezium).</p><p>The event is published if and only if the transaction commits, in commit order. The relay may publish twice, so consumers dedupe by event ID.</p><p><a href=""https://butyavk.github.io/system-design/async/event-streaming/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-outbox"
"Message queue or log: when do you use which?"	"<p><strong>Queue</strong> (RabbitMQ, SQS): a message is deleted on ack; competing workers share one queue; per-message retries and DLQ are built in. Use it to distribute <em>work</em>.</p><p><strong>Log</strong> (Kafka, Kinesis, Pulsar): records stay until retention; many independent groups read with their own offsets and can replay; strict order per partition. Use it to distribute <em>facts</em>.</p><p><a href=""https://butyavk.github.io/system-design/async/event-streaming/"">Read more on the site</a></p>"	"system-design sdp::async"	"sdp-en-async-queue-vs-log"
"Which HTTP methods are safe, which are idempotent, and how do you retry a POST safely?"	"<p><strong>Safe</strong> (no state change requested): GET, HEAD, OPTIONS, TRACE and the new QUERY (RFC 10008). <strong>Idempotent</strong>: the safe ones plus PUT and DELETE, so clients and proxies can retry them.</p><p>POST and PATCH are neither; make them retry-safe with an <strong>idempotency key</strong>. In practice caches store GET and HEAD responses; QUERY is cacheable, but support is still new.</p><p><a href=""https://butyavk.github.io/system-design/communication/http/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-http-methods"
"<code>no-cache</code> vs <code>no-store</code>, <code>private</code> vs <code>s-maxage</code>: what does each mean?"	"<ul><li><code>no-cache</code>: may be stored, but must be <strong>revalidated</strong> before each use. <code>no-store</code>: must not be stored at all.</li><li><code>private</code>: keep out of shared caches (anything personalised). <code>s-maxage</code>: freshness for shared caches such as CDNs, overriding <code>max-age</code>.</li></ul><p>Revalidate cheaply with <code>ETag</code> + <code>If-None-Match</code> → <code>304 Not Modified</code>.</p><p><a href=""https://butyavk.github.io/system-design/communication/http/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-cache-control"
"What does HTTP/3 fix compared with HTTP/2, and what does it cost?"	"<p>HTTP/2 multiplexes streams over one TCP connection, but one lost packet stalls all of them. HTTP/3 runs over <strong>QUIC</strong> (UDP): loss stalls only its own stream, transport and TLS handshakes are combined, and connections survive a network change.</p><p>Costs: UDP is blocked on some networks (keep a fallback), more CPU per byte, and less mature self-hosted tooling.</p><p><a href=""https://butyavk.github.io/system-design/communication/http/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-http3"
"How many round trips before the first response byte on a new HTTPS connection?"	"<ul><li>New TCP + TLS 1.2: 4 (400 ms at 100 ms RTT).</li><li>New TCP + TLS 1.3: 3.</li><li>New QUIC (HTTP/3): 2.</li><li>QUIC resumption with 0-RTT, or a reused warm connection: 1.</li></ul><p>So reuse and pool connections. Accept 0-RTT early data only for safe, idempotent requests, because it can be replayed.</p><p><a href=""https://butyavk.github.io/system-design/communication/http/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-handshake-cost"
"TCP vs UDP: what do you get and give up with each?"	"<p><strong>TCP</strong>: a one-round-trip handshake, then reliable, in-order bytes with flow control (protects the receiver) and congestion control (protects the network). One lost segment stalls everything behind it.</p><p><strong>UDP</strong>: an 8-byte header and nothing else — no connection, ordering, retransmission or congestion control. Used when late data is useless (voice, games), for DNS and DHCP, and for broadcast. You own congestion control and amplification protection.</p><p><a href=""https://butyavk.github.io/system-design/communication/tcp-and-udp/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-tcp-udp"
"Why are new TCP connections expensive, and why pool them?"	"<ul><li>Handshake round trips, plus TLS.</li><li><strong>Slow start</strong>: a new connection starts with 10 segments (about 14.6 KB), so a 1 MB response needs about 7 round trips, 0.7 s at 100 ms RTT.</li><li>TIME_WAIT: about 28,000 ephemeral ports run out at roughly 470 new connections/s to one backend.</li><li>500 app instances × 20 database connections = 10,000 server connections.</li></ul><p><a href=""https://butyavk.github.io/system-design/communication/tcp-and-udp/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-connection-cost"
"RPC (gRPC) or REST: which do you choose, and where?"	"<p><strong>REST + JSON + OpenAPI</strong> for public APIs: any HTTP client works, HTTP caching applies, conventions are familiar.</p><p><strong>gRPC</strong> between internal services: typed Protobuf contracts, compact encoding, deadlines, streaming and generated clients over HTTP/2. Browsers need gRPC-Web or Connect.</p><p>Many organisations run gRPC inside and expose REST through a gateway.</p><p><a href=""https://butyavk.github.io/system-design/communication/rpc-and-rest/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-rpc-rest"
"How do you paginate and version a public API?"	"<p><strong>Pagination</strong>: cursors, not offsets. An opaque token encoding the last position stays fast at any depth and stable under inserts; offsets slow down with depth and skip or duplicate items.</p><p><strong>Versioning</strong>: prefer additive, backward-compatible changes; reserve a new major version (<code>/v1/…</code>) for breaking ones, and announce retirement with <code>Deprecation</code> and <code>Sunset</code> headers.</p><p><a href=""https://butyavk.github.io/system-design/communication/rpc-and-rest/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-pagination-versioning"
"GraphQL: when does it fit, and what problems must you handle?"	"<p>Fits many clients needing different views of a rich, connected domain: one round trip per screen and no over-fetching.</p><p>Handle <strong>N+1</strong> resolvers with a per-request DataLoader (batch and memoise), <strong>weak HTTP caching</strong> (all POST to one endpoint; use persisted queries) and <strong>query cost</strong>: limit depth and page size and rate-limit by cost. Avoid it for simple CRUD or internal calls.</p><p><a href=""https://butyavk.github.io/system-design/communication/api-styles/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-graphql"
"Long polling, SSE or WebSockets: which do you pick for server push?"	"<ul><li><strong>SSE</strong>: one-way server → client over plain HTTP, with built-in reconnect via <code>Last-Event-ID</code>. Notifications, dashboards, LLM token streams.</li><li><strong>WebSockets</strong>: full duplex, low latency. Chat, collaboration, games; you must build reconnect, heartbeats and acks.</li><li><strong>Long polling</strong>: the universal fallback when streaming is blocked.</li></ul><p>A message reaches a user on another server through a pub/sub layer between connection gateways.</p><p><a href=""https://butyavk.github.io/system-design/communication/api-styles/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-push"
"What must the sender and the receiver of webhooks do?"	"<p><strong>Sender</strong>: deliver from a queue; retry with backoff and jitter for hours or days (Stripe retries for up to three days); sign each delivery with HMAC-SHA256 over ID, timestamp and raw body; block private addresses to prevent SSRF.</p><p><strong>Receiver</strong>: verify the signature on the raw body, reject stale timestamps, answer <code>2xx</code> fast, dedupe by event ID (delivery is at least once) and don't assume order.</p><p><a href=""https://butyavk.github.io/system-design/communication/api-styles/"">Read more on the site</a></p>"	"system-design sdp::communication"	"sdp-en-comm-webhooks"
"Metrics, traces, logs: which question does each answer, and how are they linked?"	"<p><strong>Metrics</strong> say <em>that</em> something is wrong, cheaply. <strong>Traces</strong> say <em>where</em> the time went. <strong>Logs</strong> say <em>why</em>.</p><p>Link them with a shared trace ID: alert on a metric, open an exemplar trace from the bad minute, then find its logs by trace ID. OpenTelemetry is the vendor-neutral standard for all three.</p><p><a href=""https://butyavk.github.io/system-design/reliability/observability/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-three-signals"
"What do RED and USE stand for, and where does each apply?"	"<p><strong>RED</strong>, for every request-driven service: <strong>R</strong>ate, <strong>E</strong>rrors, <strong>D</strong>uration (a latency distribution).</p><p><strong>USE</strong>, for every resource, including thread pools, connection pools and queues: <strong>U</strong>tilisation, <strong>S</strong>aturation (work waiting), <strong>E</strong>rrors.</p><p>Google's four golden signals (latency, traffic, errors, saturation) combine the two. Measure the latency of successes and failures separately.</p><p><a href=""https://butyavk.github.io/system-design/reliability/observability/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-red-use"
"How do you alert on an SLO? Give the burn-rate thresholds for a 99.9% SLO."	"<p>Alert on the <strong>burn rate</strong>: how fast the error budget is being spent (1 = exactly the whole budget in 30 days).</p><ul><li>Page: burn rate 14.4 over 1 h and 5 min (2% of the budget used).</li><li>Page: 6 over 6 h and 30 min (5%).</li><li>Ticket: 1 over 3 days and 6 h (10%).</li></ul><p>The long window makes the alert significant; the short one lets it stop soon after the problem does.</p><p><a href=""https://butyavk.github.io/system-design/reliability/observability/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-burn-rate"
"Why must metric labels be bounded?"	"<p>Every distinct label combination is a separate time series, and they multiply: 50 endpoints × 4 methods × 5 status classes × 200 pods × 14 histogram series = 2.8 million. Add <code>customer_id</code> with 10,000 values and you get 28 billion.</p><p>Keep metric labels bounded (endpoint template, region, status class); put user IDs, order IDs and URLs into traces and logs.</p><p><a href=""https://butyavk.github.io/system-design/reliability/observability/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-cardinality"
"How does a token bucket rate limiter work?"	"<p>A bucket holds up to <code>b</code> tokens and refills at <code>r</code> per second; each request takes a token or is rejected (or delayed). Over any interval <code>t</code>, at most <code>b + r·t</code> requests pass: bursts up to <code>b</code>, long-run average <code>r</code>.</p><p>You store just two numbers per key (tokens and last refill time) and refill lazily. It is the default for APIs.</p><p><a href=""https://butyavk.github.io/system-design/reliability/rate-limiting/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-token-bucket"
"What is wrong with a fixed-window limiter, and how does the sliding-window counter fix it?"	"<p>With 100 per minute, a client can send 100 at 10:15:59 and 100 at 10:16:00: up to <strong>2× the limit</strong> at a boundary.</p><p>The sliding-window counter weights the previous window by its overlap: 15 s into the minute, <code>84 × 45/60 + 36 = 99</code>, so one more request is allowed. Cloudflare measured only 0.003% wrong decisions over 400 million requests.</p><p><a href=""https://butyavk.github.io/system-design/reliability/rate-limiting/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-windows"
"Distributed rate limiting in Redis: what are the classic bugs, and what if Redis is down?"	"<p>Bug 1: <strong>check-then-act</strong> (<code>GET</code>, compare, <code>INCR</code>) lets two nodes both allow at 99. Bug 2: <code>INCR</code> then a separate <code>EXPIRE</code>; a crash in between leaves a key that never expires.</p><p>Fix: <code>INCR</code> with <code>EXPIRE … NX</code> in one <code>MULTI</code>, or a Lua script using the server's <code>TIME</code>.</p><p>If the store fails, decide in advance: fail open (most public APIs, with a coarse local limit) or fail closed. Reject with <code>429</code> and <code>Retry-After</code>.</p><p><a href=""https://butyavk.github.io/system-design/reliability/rate-limiting/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-distributed-limit"
"How do cascading failures happen? What is a metastable failure?"	"<p>A feedback loop: failure causes more load or waiting, which causes more failures. Survivors take the dead replica's load; a slow dependency fills pools (by Little's law, 20 ms → 2 s means 100× in flight); 3 attempts at each of 4 layers turn one request into 3⁴ = 81 calls.</p><p><strong>Metastable</strong>: the trigger is gone, but retries, queues and cold caches keep load above capacity. Recovery needs load well below the original level.</p><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-cascading"
"How do you set timeouts, and why propagate a deadline?"	"<p>Every remote call needs a timeout (gRPC sets no deadline by default). Set it slightly above the dependency's p99.9, not a round “30 s”, and separate connect from request timeouts.</p><p>Better, the edge sets an end-to-end budget (say 800 ms) and each hop passes on the <em>remaining</em> time, so services stop working on requests nobody is waiting for. Dropping abandoned work is the cheapest load shedding there is.</p><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-timeouts"
"What are the rules for retries that don't cause retry storms?"	"<ul><li>Retry only safe operations: reads, idempotent writes, writes with an idempotency key. Never retry 4xx except 408 and 429.</li><li>Exponential backoff with <strong>full jitter</strong>: <code>sleep = random(0, min(cap, base × 2^attempt))</code>.</li><li>Cap attempts (about three) and respect the caller's deadline.</li><li>Retry at <strong>one layer</strong> only.</li><li>Use a <strong>retry budget</strong> (about 10% of requests): worst-case load grows about 1.1× instead of 3×.</li></ul><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-retries"
"The payment call timed out. How does an idempotency key make the retry safe?"	"<p>The client generates one unique key per <em>logical</em> operation and sends it with every attempt. The server:</p><ol><li>stores the key with a request fingerprint, atomically, before doing the work;</li><li>replays the stored response for a repeat with the same parameters;</li><li>returns an error if the parameters differ;</li><li>answers <code>409</code> while the original is still running;</li><li>expires keys after a retention period (Stripe: 24 hours).</li></ol><p>Store the key in the same transaction as the effect.</p><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-idempotency-key"
"Explain the three states of a circuit breaker."	"<ul><li><strong>Closed</strong>: calls pass through; failures and slow calls are counted over a sliding window.</li><li><strong>Open</strong>: calls fail immediately or go to a fallback, giving the dependency room to recover.</li><li><strong>Half-open</strong>: after a wait, a few trial calls go through; success closes it, failure opens it again.</li></ul><p>Keep one breaker per endpoint and shard, and alert on its state, because breakers hide failures.</p><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-circuit-breaker"
"Bulkheads and load shedding: what does each protect against?"	"<p><strong>Bulkhead</strong>: each dependency or tenant gets its own bounded pool of threads or connections, so a hung recommendations service fills only its own 20 connections and checkout keeps working. At scale this becomes a cell-based architecture.</p><p><strong>Load shedding</strong>: under overload, reject early and cheaply, by priority, so the rest finish within their deadlines. Otherwise goodput (useful completed work) collapses while throughput still looks high.</p><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-bulkhead-shedding"
"What are hedged requests, and what do they buy?"	"<p>If a request has not answered within about the p95 latency, send a copy to another replica and take whichever reply comes first.</p><p>In <em>The Tail at Scale</em>, hedging after 10 ms cut p99.9 from 1,800 ms to 74 ms for only 2% more requests. Only for idempotent reads; cancel the slower copy and cap hedges with a budget.</p><p><a href=""https://butyavk.github.io/system-design/reliability/resilience-patterns/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-hedged"
"Authentication vs authorisation, and where do you check each?"	"<p><strong>AuthN</strong> proves <em>who</em> you are; <strong>authZ</strong> decides <em>what</em> you may do with this object. AuthZ failures, such as fetching <code>/invoices/1043</code> after being allowed only <code>/invoices/1042</code>, are far more common: broken access control is the top web risk.</p><p>Authenticate at the gateway, but check authorisation in the service, on every request and every object. Store passwords only as slow salted hashes (Argon2id).</p><p><a href=""https://butyavk.github.io/system-design/reliability/security/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-authn-authz"
"Server-side sessions or JWTs?"	"<p><strong>Session</strong>: a random ID in a cookie, looked up in a shared store. Revocation is immediate. Best for browser apps, with <code>HttpOnly</code>, <code>Secure</code> and <code>SameSite</code> cookies.</p><p><strong>JWT</strong>: signed claims verified locally, with no lookup, so any service can check them, but revocation is hard. Keep them short-lived with revocable refresh tokens, pin the algorithm, validate <code>iss</code>, <code>aud</code> and <code>exp</code>, and never keep them in <code>localStorage</code>.</p><p><a href=""https://butyavk.github.io/system-design/reliability/security/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-sessions-jwt"
"What is envelope encryption, and why is it the standard?"	"<p>Data is encrypted locally with a per-object <strong>data key</strong>; only that small key is encrypted by a KMS whose root keys never leave its HSMs.</p><p>Bulk data never travels to the KMS, every KMS call is authorised and audited, rotating the root key needs no re-encryption of terabytes, and destroying a key makes everything under it unreadable. Encryption at rest doesn't stop someone with valid credentials: control who can use the keys.</p><p><a href=""https://butyavk.github.io/system-design/reliability/security/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-envelope"
"Injection, XSS, CSRF, SSRF: the main defence against each?"	"<ul><li><strong>Injection</strong>: parameterised queries; allowlists for identifiers.</li><li><strong>XSS</strong>: context-aware output encoding, HTML sanitisation, plus a Content Security Policy.</li><li><strong>CSRF</strong>: <code>SameSite</code> cookies, rejecting cross-site requests via <code>Sec-Fetch-Site</code>, and never changing state on GET.</li><li><strong>SSRF</strong> (webhooks, link previews): resolve the host, block private and link-local ranges, send traffic through an egress proxy.</li></ul><p><a href=""https://butyavk.github.io/system-design/reliability/security/"">Read more on the site</a></p>"	"system-design sdp::reliability"	"sdp-en-rel-input"
"Typical latency of an L1 cache hit, an L2 hit and a main memory (DRAM) reference?"	"<p>L1 about <strong>1 ns</strong>, L2 about <strong>3.5 ns</strong>, DRAM about <strong>100 ns</strong> (70 ns on a DDR5 desktop, 110–130 ns on many-core servers).</p><p>They have barely changed since 2012, because clock speeds stopped at 3–6 GHz and cache latency is a fixed number of cycles. Memory bandwidth grew; latency did not.</p><p><a href=""https://butyavk.github.io/system-design/reference/latency-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-cpu-memory"
"Random 4 KB read from NVMe vs a round trip inside an availability zone: which is faster?"	"<p>The NVMe read: about <strong>50 µs</strong> at queue depth 1, against about <strong>200 µs</strong> for a same-zone round trip.</p><p>In 2012 a network round trip beat a disk seek by twenty times. Today a local NVMe read is cheaper than a network hop, so a remote cache earns its place when it saves a query, computation or a cross-region trip, not just a disk read.</p><p><a href=""https://butyavk.github.io/system-design/reference/latency-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-nvme-vs-network"
"Round-trip times: within a zone, between zones, US East ↔ Western Europe, California ↔ Netherlands, the other side of the world?"	"<ul><li>Within a zone: ~200 µs (about 5,000 sequential trips per second)</li><li>Between zones: ~1 ms (~1,000/s)</li><li>US East ↔ Western Europe: ~80 ms (~12/s)</li><li>California ↔ Netherlands: ~145 ms (~7/s)</li><li>Other side of the world: ~280 ms (3–4/s)</li></ul><p>Light in fibre covers about 200 km per ms, so sequential cross-region calls are the most expensive part of most requests.</p><p><a href=""https://butyavk.github.io/system-design/reference/latency-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-network-rtt"
"How fast are hard disks, NVMe drives and cloud block volumes?"	"<ul><li>HDD random read (seek + rotation): ~<strong>10 ms</strong>, so only about 100 random IOPS per drive; 1 MB sequential ~5 ms.</li><li>NVMe: 1 MB sequential ~100 µs (7 GB/s on PCIe 4, 14 GB/s on PCIe 5), 7–14 times the 2012 SSD.</li><li>Network-attached cloud block volume I/O: ~<strong>1 ms</strong>, ten times a local NVMe drive, because every I/O crosses the network.</li></ul><p><a href=""https://butyavk.github.io/system-design/reference/latency-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-disks"
"Typical latency of a Redis/Valkey GET, an indexed PostgreSQL query, a TLS 1.3 handshake and an object storage GET?"	"<ul><li>Redis/Valkey GET in the same zone: ~<strong>250 µs</strong>; the server needs well under 1 µs, the rest is the network.</li><li>Indexed PostgreSQL query over the network: ~<strong>500 µs</strong> (19 µs over a Unix socket).</li><li>TLS 1.3 handshake within a region: ~<strong>1 ms</strong>.</li><li>Object storage first byte: ~<strong>30 ms</strong> median, with a tail to 200 ms.</li></ul><p>All of them are dominated by the round trip, so fewer round trips beat faster servers.</p><p><a href=""https://butyavk.github.io/system-design/reference/latency-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-services"
"How long does a DNS lookup take with and without a resolver cache hit?"	"<p>Resolver cache hit: ~<strong>10 ms</strong>, roughly one round trip to the resolver (under 1 ms inside a cloud VPC, 5–30 ms from home or mobile networks).</p><p>Cache miss with full recursion: ~<strong>100 ms</strong>, about 130 ms on average when servers answer, 300–400 ms with timeouts and retries. OS and browser caches answer in microseconds.</p><p><a href=""https://butyavk.github.io/system-design/reference/latency-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-dns"
"How much downtime do 99.9%, 99.99% and 99.999% allow per year and per month?"	"<ul><li>99.9%: <strong>8 h 46 min</strong> a year, 43 min 50 s a month. A human can be paged and roll back.</li><li>99.99%: <strong>52 min 36 s</strong> a year, 4 min 23 s a month. Detection and failover must be automatic.</li><li>99.999%: <strong>5 min 16 s</strong> a year, 26 s a month. No single global dependency.</li></ul><p>Each extra nine divides the budget by ten and costs roughly ten times the effort.</p><p><a href=""https://butyavk.github.io/system-design/reference/availability-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-nines"
"How do failure rate and recovery time determine availability?"	"<p><code>A = MTBF / (MTBF + MTTR)</code>. A component that fails once a month and takes 30 minutes to recover is about 99.93% available; cutting recovery to 5 minutes raises it to 99.99% without making failures any rarer.</p><p>That is why high-availability work focuses on fast detection and recovery: health checks, automatic failover, quick rollbacks, small blast radii.</p><p><a href=""https://butyavk.github.io/system-design/reference/availability-numbers/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-mttr"
"Which powers of two should you know for estimates?"	"<ul><li>2¹⁰ ≈ 10³: every ten powers add about three zeros, so 2²⁰ ≈ a million, 2³⁰ ≈ a billion, 2⁴⁰ ≈ a trillion.</li><li>2³² ≈ 4.3 billion: IPv4 addresses, unsigned 32-bit integers.</li><li>2³¹ − 1 ≈ 2.1 billion: the classic signed-integer overflow.</li><li>2⁶⁴ ≈ 1.8 × 10¹⁹: does not run out at web scale.</li></ul><p><a href=""https://butyavk.github.io/system-design/reference/powers-of-two/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-powers-of-two"
"KB vs KiB, and bits vs bytes: what are the traps?"	"<p><strong>KB, MB, GB</strong> are powers of 1,000; <strong>KiB, MiB, GiB</strong> are powers of 1,024. The gap grows from 2.4% at kilo to 10% at tera, which is why a “1 TB” disk shows up as 931 GB.</p><p>Network bandwidth is quoted in <strong>bits</strong> per second, storage in <strong>bytes</strong>: a 10 Gbit/s link moves about 1 GB/s of payload. Mixing bits and bytes is the more common slip.</p><p><a href=""https://butyavk.github.io/system-design/reference/powers-of-two/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-units"
"Convert 1 million, 100 million and 1 billion requests per day into requests per second."	"<p>A day is 86,400 s ≈ 10⁵ s.</p><ul><li>1 million/day ≈ <strong>12/s</strong></li><li>100 million/day ≈ <strong>1,200/s</strong></li><li>1 billion/day ≈ <strong>12,000/s</strong></li></ul><p>Then find the peak: typically 2–3× the daily average, up to 10× for launches. Size servers for the peak and storage for the average.</p><p><a href=""https://butyavk.github.io/system-design/start/estimation/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-daily-to-rate"
"Roughly what can one machine handle in 2026?"	"<ul><li>Stateless web or API server: 1,000–10,000 requests/s.</li><li>PostgreSQL or MySQL primary on a large instance: 10,000+ simple writes/s, 50,000+ indexed reads/s, tens of TB.</li><li>Valkey or Redis node: 100,000+ operations/s.</li><li>Kafka-style broker: hundreds of MB/s of writes.</li><li>Server memory 256 GB – 2 TB; network port 25–100 Gbit/s.</li></ul><p><a href=""https://butyavk.github.io/system-design/start/estimation/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-machine-capacity"
"Photo sharing: 20 M daily users, a 2 MB photo every other day, 50 views each. What dominates the design?"	"<p>Request rates are modest (about 120 uploads/s and 6,000 views/s), but <strong>egress and storage dominate</strong>: about 90 Gbit/s of views (370 Gbit/s at peak) and about 7 PB of new data a year, 220 PB over ten years with three copies.</p><p>So: a CDN in front, object storage with erasure coding and colder tiers, and metadata as a separate, much smaller problem.</p><p><a href=""https://butyavk.github.io/system-design/start/estimation/"">Read more on the site</a></p>"	"system-design sdp::numbers"	"sdp-en-num-photo-estimate"
"What are the seven steps of the system design interview framework?"	"<ol><li>Clarify requirements.</li><li>Estimate.</li><li>Define the API and data model.</li><li>Sketch the high-level design.</li><li>Deep-dive into one or two components.</li><li>Scale it and break it: bottlenecks, failures, trade-offs.</li><li>Wrap up against the requirements.</li></ol><p><a href=""https://butyavk.github.io/system-design/start/interview-framework/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-seven-steps"
"How do you budget time in a 45-minute design interview?"	"<p>About 40 minutes of design time: requirements 4, estimates 3, API and data model 4, high-level design 10, deep dives 11, scaling and failures 6, wrap-up 2.</p><p>Checkpoint: by the halfway mark a complete high-level design should be on the board. If you are still on requirements at minute 15, state your assumptions and move on.</p><p><a href=""https://butyavk.github.io/system-design/start/interview-framework/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-time-budget"
"Functional vs non-functional requirements: how do you capture them?"	"<p><strong>Functional</strong>: what the system does — agree on three to five core use cases and explicitly park the rest.</p><p><strong>Non-functional</strong>: how well it does it — as numbers, not adjectives: “p99 under 200 ms”, “99.99% for redirects”, “no lost links”.</p><p>Ask about users, scale, read/write ratio, data size, latency, consistency, geography and constraints. If told “you decide”, decide out loud.</p><p><a href=""https://butyavk.github.io/system-design/start/interview-framework/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-requirements"
"What makes a back-of-the-envelope estimate useful in an interview?"	"<p>A <strong>conclusion</strong>. “About 3,500 reads a second at peak, so one database with a cache is enough”; “220 PB, so object storage with tiering.”</p><p>State assumptions first, keep units on every number, size for the peak, count replicas and overhead, round to one significant figure. A table of numbers without “so we need X” is half an answer.</p><p><a href=""https://butyavk.github.io/system-design/start/estimation/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-estimates-conclusion"
"How do you run a deep dive, and what do you stress-test afterwards?"	"<p>Pick one or two components where the requirements are hardest (uniqueness, a hot path, consistency, data growth). Lay out two or three options, compare them against the written requirements, pick one and say what you give up.</p><p>Then, component by component: what breaks first at 10× load, and what happens when it fails? Name the fixes and their costs.</p><p><a href=""https://butyavk.github.io/system-design/start/interview-framework/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-deep-dive"
"Name the most common mistakes in system design interviews."	"<ul><li>Jumping to the diagram before requirements and scale.</li><li>Over-engineering: microservices, Kafka and five databases for a one-server problem.</li><li>Buzzwords without saying what they do here and cost.</li><li>Estimates that are never used.</li><li>No trade-offs and no answer to “what if this node dies?”</li><li>Going deep too early, monologuing, losing track of time.</li></ul><p><a href=""https://butyavk.github.io/system-design/start/interview-framework/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-mistakes"
"What separates a senior performance from a mid-level one?"	"<p><strong>Mid-level</strong>: drives with some help and produces a working end-to-end design with standard components.</p><p><strong>Senior</strong>: drives the whole interview, lets numbers justify choices, goes deep on the hardest component, raises bottlenecks and failure modes before being asked, and compares alternatives with clear trade-offs.</p><p><strong>Staff+</strong>: also frames or challenges the problem and covers operations, cost, migration and when not to build.</p><p><a href=""https://butyavk.github.io/system-design/start/interview-framework/"">Read more on the site</a></p>"	"system-design sdp::interview"	"sdp-en-int-senior-signals"
"URL shortener: how do you generate short keys?"	"<p>Default: a <strong>random 7–8 character Base62 key</strong> plus an atomic “insert if absent”; on conflict, draw again. 62⁷ ≈ 3.5 × 10¹², so with 360 M keys only about 1 insert in 9,800 retries — but the retry path is mandatory.</p><p>For the shortest keys, lease counter ranges and pass them through a scrambling permutation, because raw counters are enumerable.</p><p><a href=""https://butyavk.github.io/system-design/practice/url-shortener-pastebin/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-short-keys"
"URL shortener: 301 or 302 redirect?"	"<p><strong>301</strong> is cacheable by default, so repeat clicks may never reach you: less load, but lost analytics, and a takedown doesn't reach browsers that cached it.</p><p><strong>302</strong> brings every click back: accurate counts, editable links and instant takedown of a phishing link, at the cost of serving every repeat visit. A middle ground is a 301 with a short <code>max-age</code>.</p><p><a href=""https://butyavk.github.io/system-design/practice/url-shortener-pastebin/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-301-302"
"Twitter home timeline: fan-out on write or fan-out on read?"	"<p><strong>Hybrid.</strong> Push an ordinary user's tweet ID into each active follower's cached timeline (about 800 IDs per user); reads are one list fetch plus a multiget. <strong>Pull</strong> tweets from accounts with millions of followers and merge them at read time.</p><p>Why: reads outnumber tweets about 17×, so push is cheaper overall, but one celebrity tweet would mean 5 M inserts.</p><p><a href=""https://butyavk.github.io/system-design/practice/twitter-timeline/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-fanout"
"Twitter search: how do you partition the inverted index?"	"<p>By <strong>document</strong> (tweet ID), not by term: term sharding sends every popular term to one hot shard and makes multi-term queries cross shards.</p><p>Each query scatters to all shards in the relevant time tiers (an in-memory realtime tier, older tiers on SSD), takes the top K per shard, merges, re-ranks and hydrates. An indexer fed from the tweet stream keeps it fresh.</p><p><a href=""https://butyavk.github.io/system-design/practice/twitter-timeline/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-twitter-search"
"Web crawler: how does the URL frontier keep both priority and politeness?"	"<p><strong>Front queues</strong> hold URLs by priority; a selector routes them to <strong>back queues</strong>, one per host; a <strong>heap</strong> keyed by “earliest time this host may be contacted” picks the next host.</p><p>If each host gets one request about every 10 s, sustaining 1,650 fetches/s needs at least 16,500 hosts with queued work. Respect robots.txt (RFC 9309), cached up to 24 hours.</p><p><a href=""https://butyavk.github.io/system-design/practice/web-crawler/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-crawler-frontier"
"Web crawler: how do you deduplicate URLs and content?"	"<p><strong>URLs</strong>, before they enter the frontier: normalise, then check a “seen” set or a Bloom filter (about 12 GB for 10 B URLs at 1% false positives, which only skips a few new URLs).</p><p><strong>Content</strong>, after fetching: an exact hash for identical bodies, and <strong>SimHash</strong> for near-duplicates — 64-bit fingerprints within Hamming distance 3, found with the block trick.</p><p><a href=""https://butyavk.github.io/system-design/practice/web-crawler/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-crawler-dedup"
"Social graph: how do you find the shortest path between two users at scale?"	"<p><strong>Bidirectional BFS</strong>, always expanding the smaller frontier. With 50 friends each, a path of length 4 touches about 5,000 nodes instead of about 6 million.</p><p>Adjacency lists live in memory on person servers sharded by user ID. Fetch each BFS level with one batched call per shard, in parallel, so round trips equal the depth (about 4), not the number of friends.</p><p><a href=""https://butyavk.github.io/system-design/practice/social-graph/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-social-bfs"
"Search query cache: what goes into the key, and how do results stay fresh?"	"<p>Key: the <strong>normalised query plus everything that changes the page</strong> — locale, safe-search, page number, index version. Leaving one out serves the wrong results.</p><p>Freshness: a TTL with jitter plus the <strong>index version in the key</strong>, so a new snapshot gives new keys and old entries age out. Shard with consistent hashing, keep a local tier for the hottest queries, and coalesce misses.</p><p><a href=""https://butyavk.github.io/system-design/practice/search-query-cache/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-query-cache"
"Sales rank by category: how do you compute and serve top-N lists?"	"<p>Sales events go to a durable log; checkout never waits for ranking. Count units per <code>(category, product)</code> over a sliding 7-day window — an hourly batch job classically, a windowed stream job today — and keep a <strong>bounded heap per category</strong>, not a global sort.</p><p>The read side is tiny (top 100 × 1,000 categories ≈ 1.6 MB): publish versioned snapshots and cache them in memory and at the CDN.</p><p><a href=""https://butyavk.github.io/system-design/practice/sales-rank/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-sales-rank"
"Personal finance tracker: how do you ingest bank transactions without duplicates or lost data?"	"<p>Store only a consented token, encrypted in a vault — never the bank password. A scheduler and provider webhooks feed a job queue; sync workers pull incremental changes <strong>by cursor</strong> and <strong>upsert</strong> on a unique provider transaction ID, saving the cursor in the same transaction.</p><p>A circuit breaker per institution keeps a 6-hour bank outage contained; money is integer cents, never floats.</p><p><a href=""https://butyavk.github.io/system-design/practice/personal-finance-mint/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-mint"
"Scaling a web app from one box to millions of users: in what order?"	"<p>It is a loop: load test → profile → fix the top bottleneck → repeat. The usual order:</p><ol><li>Separate the database.</li><li>Stateless app tier behind a load balancer.</li><li>Cache and read replicas.</li><li>Object storage and a CDN for static content.</li><li>Queues and async workers.</li><li>Then partition data and go multi-region.</li></ol><p>Name what each step buys and costs.</p><p><a href=""https://butyavk.github.io/system-design/practice/scaling-to-millions/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-scaling-order"
"How do you approach an unfamiliar design question?"	"<p>Find its <strong>one core difficulty</strong> — fan-out, ordering, hot keys, exactly-once or geography — in the first five minutes, and spend most of the interview there.</p><p>Use the framework: requirements, estimates, high-level design, deep dive, scaling. Read reference architectures only after sketching your own answer, and compare trade-offs rather than copying a company's design.</p><p><a href=""https://butyavk.github.io/system-design/practice/more-questions/"">Read more on the site</a></p>"	"system-design sdp::practice"	"sdp-en-prac-core-difficulty"
"Hash map: how do you keep operations O(1) on average?"	"<p>Buckets indexed by <code>hash(key) % capacity</code>, each a short list of entries (separate chaining). Keep the <strong>load factor</strong> (<code>size / capacity</code>) under 0.75; when it goes over, <strong>double</strong> the array and rehash every entry. Doubling means each entry moves a constant number of times on average, so inserts are amortised <code>O(1)</code>.</p><p>Worst case is <code>O(n)</code> when all keys collide; defences are randomised hashing (SipHash) or tree-ified buckets.</p><p><a href=""https://butyavk.github.io/system-design/ood/hash-map/"">Read more on the site</a></p>"	"system-design sdp::ood"	"sdp-en-ood-hash-map"
"LRU cache: which data structures, and what is the key trick?"	"<p>A <strong>dict</strong> (key → node) for <code>O(1)</code> lookup plus a <strong>doubly linked list</strong> in recency order. <code>get</code> and <code>put</code> move the node to the head; eviction removes the tail.</p><p>The trick: each node stores <strong>its own key</strong>, so after unlinking the tail you can delete it from the dict in <code>O(1)</code>. Sentinel head and tail nodes remove the empty-list special cases.</p><p><a href=""https://butyavk.github.io/system-design/ood/lru-cache/"">Read more on the site</a></p>"	"system-design sdp::ood"	"sdp-en-ood-lru"
"Parking lot: how do you model “does this vehicle fit this spot?”"	"<p>Make <code>Size</code> an <strong>ordered</strong> enum; then fitting is one comparison, <code>spot.size &gt;= vehicle.size</code>, and vehicle subclasses carry only a size and the number of spots they need.</p><p>Single-spot vehicles take the <strong>smallest</strong> spot that fits (best fit), keeping large spots for buses; a bus needs 5 adjacent large spots in one row. <code>park</code> returns a <code>Ticket</code> that <code>leave</code> uses to free the spots.</p><p><a href=""https://butyavk.github.io/system-design/ood/parking-lot/"">Read more on the site</a></p>"	"system-design sdp::ood"	"sdp-en-ood-parking-lot"
"Call center: how does escalation work without special routing code?"	"<p>Each <code>Call</code> records the <strong>minimum rank</strong> allowed to take it (<code>OPERATOR &lt; SUPERVISOR &lt; DIRECTOR</code>). Escalation just <strong>raises that minimum and dispatches the call again</strong>, so one routing path handles new, escalated and queued calls.</p><p>Only <code>CallCenter</code> routes. With one FIFO queue per rank, a freed employee takes the waiting call needing the highest rank they have.</p><p><a href=""https://butyavk.github.io/system-design/ood/call-center/"">Read more on the site</a></p>"	"system-design sdp::ood"	"sdp-en-ood-call-center"
"Deck of cards: how do you model cards and score aces in blackjack?"	"<p><code>Card</code> is an immutable value (<code>rank</code>, <code>suit</code>, both enums) with no game logic; <code>Deck</code> builds, shuffles and deals; <code>Hand.score()</code> is overridden only in <code>BlackjackHand</code>.</p><p>Aces: count each as 1, then add 10 <strong>once</strong> if that doesn't bust. Two aces as 11 would be 22, so at most one ace can ever count high.</p><p><a href=""https://butyavk.github.io/system-design/ood/deck-of-cards/"">Read more on the site</a></p>"	"system-design sdp::ood"	"sdp-en-ood-deck-of-cards"
"Online chat: what keeps the object model consistent?"	"<p>Entities refer to each other by <strong>id</strong>, not by object, so a friendship or membership changes in one place and the model maps directly to tables later. One <code>ChatService</code> owns everything and enforces cross-user rules.</p><p>A private chat is keyed by the <strong>unordered pair</strong> of users (<code>frozenset</code>), so A→B and B→A find the same chat.</p><p><a href=""https://butyavk.github.io/system-design/ood/online-chat/"">Read more on the site</a></p>"	"system-design sdp::ood"	"sdp-en-ood-online-chat"
