03 / Scale and reliability

System design interview questions

Reason about APIs, state, scale, and reliability. 144 walkthroughs cover APIs, storage, messaging, scheduling, caching, and reliable delivery.

Work through a complete design.

From the API contract to failure behavior.

01

Design a distributed rate limiter

Token buckets, atomic decisions, hot keys, and regional budgets.

10 min read
02

Design a URL shortener

Allocate codes safely, accelerate redirects, and make revocation and analytics explicit.

7 min read
03

Design a chat system

Separate durable messages from connections, and reason about ordering, retries, and offline delivery.

7 min read
04

Design a news feed

Compare push and pull fan-out, handle hot authors, and keep visibility checks current.

7 min read
05

Design a file-storage service

Coordinate resumable uploads, metadata, versions, and revocable access.

7 min read
06

Design a web crawler

Schedule polite fetches, bound untrusted inputs, and build a useful revisit policy.

7 min read
07

Design a distributed cache

Choose a consistency contract, prevent stampedes, and plan for the moment the cache disappears.

4 min read
08

Message Queue System Design: Delivery, Retries and Backlog

Design a durable message queue with at-least-once delivery, idempotent effects and worker leases. Calculate backlog recovery and the capacity consumed by retries.

4 min read
09

Design a distributed job scheduler

Separate schedules from executions, claim work safely, and fence workers that have lost ownership.

4 min read
10

Design an inventory reservation system

Prevent overselling with atomic state transitions, explicit expiry, and reconciliation for uncertain outcomes.

4 min read
11

Design a notification delivery service

Track durable intent, provider attempts, user preferences, and ambiguous delivery outcomes.

4 min read
12

Design a search autocomplete service

Serve fresh prefix suggestions with predictable latency, careful normalization, and bounded personalization.

4 min read
13

Design a metrics ingestion platform

Control cardinality, distinguish event time from arrival time, and preserve meaning through aggregation.

4 min read
14

Design a video streaming service

Separate upload processing from playback, and reason about encoding, cacheability, and access control.

4 min read
15

Design a reliable webhook delivery platform

Make delivery durable, bound retries, and explain why an acknowledgement cannot prove exactly-once processing.

5 min read
16

Design a coding-agent execution platform

Separate reasoning from execution and make permissions, retries, and recovery part of the architecture.

5 min read
17

GPU Scheduler System Design: Fairness and Preemption

Design a GPU scheduler with quota admission, gang placement, checkpoint recovery and fair sharing. Calculate fragmentation and the cost of preemption.

6 min read
18

Distribute and safely activate a large model

Find the bandwidth bottleneck, verify immutable chunks, and separate downloaded bytes from safe production activation.

7 min read
19

Device Configuration Sync: Offline Conflicts and Recovery

Design configuration synchronization across offline devices using revisions, conflict handling and desired versus applied state. Work through reconnect failures.

7 min read
20

Ad Frequency Capping System Design: Rolling Windows and Races

Design ad frequency capping with atomic admission, rolling windows and retry deduplication. Work through cap changes, race conditions and failure policy.

9 min read
21

Handle oversized inputs in a shared AI playground

Bound uploads, extraction and token work while preserving permissions, provenance and honest completeness guarantees.

6 min read
22

Design a change-data-capture pipeline

Connect snapshots to live changes, make replay safe, and calculate the cost of falling behind.

7 min read
23

Design token usage accounting and reconciliation

Reserve budgets before execution, meter streaming work and reconcile retries without double charging.

7 min read
24

Design an experimentation assignment and exposure platform

Deterministic assignment, enrollment, exposure semantics, telemetry loss and experiment quality.

9 min read
25

Design a double-entry payment ledger

Worked wallet entries, atomic holds, idempotent posting and ledger recovery.

9 min read
26

Collaborative Editor System Design: CRDTs, Sync and Presence

Design a collaborative editor with CRDT updates, durable synchronization and bounded presence traffic. Calculate fan-out and handle offline clients safely.

9 min read
27

Design distributed training checkpoint storage

Immutable staging, atomic publication, checkpoint bandwidth and tested restoration.

9 min read
28

Distributed Lock System Design: Leases and Fencing

Design distributed locks with lease expiry, atomic fencing checks and safe recovery. Work through stale workers, duplicate writes and external-service limits.

10 min read
29

Design a schema registry for event producers

Directional compatibility, transitive checks, registration races and cache recovery.

9 min read
30

Design resumable browser event streams

Replay boundaries, application checkpoints, fan-out and slow clients.

10 min read
31

Design tiered time-series retention and downsampling

Mergeable summaries, counter resets, late revisions and tiered queries.

10 min read
32

Design conversation history storage at scale

Immutable message trees, conditional branch updates, pagination and deletion fencing.

11 min read
33

Tamper-Evident Audit Log System Design: Integrity and Gaps

Design a tamper-evident audit log with signed manifests, independent checkpoints and verifiable exports. Distinguish integrity from capture completeness.

12 min read
34

Design a cross-shard transaction coordinator

Two-phase commit, fenced decisions, prepared-state recovery and visibility contracts.

13 min read
35

Move a live tenant between database shards

Snapshot barriers, durable replay, writer fencing and honest rollback guarantees.

13 min read
36

Object Storage Garbage Collection: Safe Deletion and Races

Design blob garbage collection with complete retention roots, atomic deletion checks and immutable generations. Analyze restore races and reclamation capacity.

14 min read
37

Allocate sortable identifiers across regions

ID bit budgets, disjoint allocation grants, clock behavior and UUID trade-offs.

13 min read
38

Limit concurrent work across service instances

Distributed permits, executor admission, fairness and oversubscription failures.

13 min read
39

Design point-in-time database recovery

Recovery points, missing logs, retention dependencies and safe cutover.

14 min read
40

Deliver messages at a future time

Time buckets, clock bounds, generation checks and overdue recovery.

14 min read
41

Allocate released reservations to a waitlist

A transactional waitlist with explicit FIFO policy, acceptance races and holding-cost calculations.

14 min read
42

Route around failing service dependencies

Scoped probes, survivor capacity, correlated failures and controlled recovery.

13 min read
43

Generate resumable customer data exports

Snapshot lifetime, immutable parts, atomic manifests and revocable download access.

13 min read
44

Build and atomically switch a distributed search index

Snapshot replay, revision fences, readiness barriers and stable pagination.

14 min read
45

Multi-Region Quota Design: Budgets and Safe Transfers

Enforce a global tenant quota with regional budgets, atomic debits and idempotent transfers. Analyze lost acknowledgments, partitions and stranded capacity.

15 min read
46

Group incoming email into reliable conversations

Message identities, missing parents, reversible merges and mailbox authorization.

14 min read
47

Roll out server configuration safely

Atomic bundles, rollback revisions, compatibility and measured rollout exposure.

14 min read
48

Fail over a regional write service safely

Partition timelines, recovery-point uncertainty, recovery budgets and external effects.

14 min read
49

Design a live-event streaming service

Segment publication, CDN capacity, live-delay budgets and timeline continuity.

14 min read
50

Allocate scarce capacity through a sealed auction

Deadline semantics, deterministic ties, payment uncertainty and hot-auction capacity.

14 min read
51

Invalidate mutable content across edge caches

HTTP freshness, generation watermarks, purge acknowledgments and origin amplification.

14 min read
52

Design a reproducible build artifact cache

Hermetic action identity, trusted publication, incomplete results and critical-path savings.

14 min read
53

Compact an event log without resurrecting deleted keys

Tombstones, stale checkpoints, consistent snapshots and net catch-up capacity.

14 min read
54

Resume long-running business workflows

History replay, lost acknowledgments, compensation, upgrades and capacity.

14 min read
55

Rotate service certificates without interrupting traffic

Dual-root migration, expiry bounds, session state, recovery and compromise response.

14 min read
56

Find nearby available resources at scale

Spatial candidates, exact distance, index lag, eligible top-k and reservation races.

14 min read
57

Compute trending items from distributed streams

Partitioning proofs, aligned windows, heavy-hitter bounds and exact ranking certificates.

15 min read
58

Book meetings across changing calendars

Interval exclusion, daylight-saving recurrence, atomic edits and external calendar limits.

15 min read
59

Design a distributed tracing ingestion service

Trace affinity, tail buffers, durable replay and sampling-biased metrics.

15 min read
60

Change a large database schema without stopping writes

Coordinate old and new writers, backfill without stale overwrites, and define the point where rollback becomes lossy.

15 min read
61

Capture a consistent distributed snapshot

Account for in-flight transfers, establish a consistent cut, and publish only a complete durable snapshot.

14 min read
62

Design a container artifact registry

Publish complete container images with resumable uploads, digest integrity, repository authorization and safe retention.

15 min read
63

Join two event streams with late arrivals

Join out-of-order events with explicit retention, provisional unmatched results and replay-safe historical corrections.

15 min read
64

Permission Revocation System Design: Caches, Leases and Streams

Design bounded permission revocation across gateways and caches. Analyze authority leases, stale refreshes, in-flight responses and signed-URL bypasses.

13 min read
65

Count reactions across regions

Separate unique reaction state from replicated totals, handle retries and undo, and rebuild counts under skew and regional failures.

15 min read
66

Execute analytical queries across workers

Plan analytical joins, budget shuffle and memory, handle hot keys, and recover tasks without duplicating results.

16 min read
67

Erasure-Coded Storage Design: Capacity and Repair

Design erasure-coded object storage with a worked 6+3 layout, failure-domain placement, acknowledgment policy and generation-safe repair.

16 min read
68

Distributed Deadlock Detection: Wait-for Graphs and Recovery

Detect distributed deadlocks with versioned wait-for graphs, stale-edge checks and coordinator-owned aborts. Distinguish deadlock from starvation and timeouts.

11 min read
69

Bound retries across a service call chain

Assume idempotent reads, a 900 ms end-to-end deadline and no guarantee that a timed-out attempt stopped executing.

6 min read
70

Schedule mixed-cost tenant jobs fairly

Assume jobs can be divided into bounded execution quanta, tenant identity is authenticated and fairness is measured in worker-seconds.

6 min read
71

Route requests with stable hashing during fleet changes

Assume cache loss is harmless and durable documents live elsewhere.

6 min read
72

Skip absent-key disk reads with Bloom filters

Assume immutable table generations and a standard Bloom filter with no deletion.

6 min read
73

Locate replica differences with Merkle trees

Assume deterministic serialization, collision-resistant hashes and versioned records with a documented conflict resolver.

6 min read
74

Cache missing DNS names without prolonging an outage

Assume an upstream recursive resolver and standards-compliant authoritative answers.

6 min read
75

Claim unique public usernames under contention

Assume a single authoritative transactional store per normalized name.

6 min read
76

Aggregate latency percentiles without averaging percentiles

Assume nonnegative latencies, explicit time windows and a mergeable quantile sketch with documented rank-error behavior.

6 min read
77

Deliver short-lived database credentials to workers

Assume workers have a trusted workload identity and the database can enforce credential revocation.

6 min read
78

Design single-use password reset links

Assume an existing account and email-delivery system.

6 min read
79

Keep a user's reads from moving backward across replicas

Assume one ordered replication history per shard and a verifiable applied position.

6 min read
80

Batch durable commits without acknowledging volatile data

Assume a write-ahead log and a storage stack that correctly implements the required flush semantics.

6 min read
81

Bound database concurrency behind a connection pool

Assume short transactional requests with a bounded database concurrency target.

6 min read
82

Count distinct identifiers across overlapping partitions

Estimate daily distinct device IDs across regions without retaining every ID centrally.

5 min read
83

Estimate hot-key frequencies with bounded sketch memory

Track query frequencies in a stream with millions of distinct strings using bounded memory.

5 min read
84

Detect concurrent document versions with vector clocks

Two offline editors update the same document.

5 min read
85

Discover membership failures without treating suspicion as proof

A thousand-node service needs a scalable membership view during packet loss.

5 min read
86

Budget compaction without starving storage writes

An LSM-based store accumulates immutable files faster than it can compact them.

5 min read
87

Skip irrelevant row groups in analytical scans

A query engine reads terabytes to answer selective date-and-region queries.

5 min read
88

Commit concurrent changes to an object-store table

Two jobs update overlapping partitions of a table stored as immutable files.

5 min read
89

Explain what overlapping read and write quorums guarantee

A replicated key-value store uses N=3, W=2 and R=2.

5 min read
90

Publish generated files with atomic name replacement

A service regenerates a configuration file while readers open it continuously.

5 min read
91

Generate bounded image variants on demand

Serve resized product images through a CDN without allowing arbitrary transformation URLs to exhaust compute and cache storage.

5 min read
92

Drain long-lived connections during a rolling upgrade

Upgrade a fleet of WebSocket gateways without abruptly dropping every active client or waiting forever for connections that never close.

5 min read
93

Resume downloads without mixing object versions

A client resumes a large interrupted download while the server may replace the file.

5 min read
94

Prevent lost edits with conditional HTTP updates

Two administrators edit the same resource from old browser tabs.

5 min read
95

Rotate encryption keys without rewriting every object

A tenant stores millions of encrypted blobs.

5 min read
96

Recover distributed shuffle outputs after worker failure

A distributed analytics job loses a worker holding intermediate partitions.

5 min read
97

Estimate a workflow deadline from its dependency graph

A team adds workers to a pipeline but completion time barely changes.

5 min read
98

Assign players to matches without double booking

Match players by skill and acceptable latency while queue time grows.

5 min read
99

Pace campaign spending under delayed usage reports

An ad campaign must spend throughout a day without exceeding an authorized budget when auction charges arrive late.

5 min read
100

Assemble daily digests from late and repeated events

Send one useful daily digest per user from many events, respecting time zones and preferences without duplicating content after retries.

5 min read
101

Manage browser push subscriptions through expiry and renewal

Deliver browser push notifications when devices rotate subscriptions, remain offline or revoke permission.

5 min read
102

Deduplicate backups when bytes shift within files

A backup service sees large files with small insertions.

5 min read
103

Find deployments affected by a dependency advisory

A dependency advisory arrives.

5 min read
104

Trace downstream datasets after an upstream correction

A source table was wrong for two days.

5 min read
105

Prevent starvation in a priority work service

Urgent jobs continually arrive and normal jobs never run.

5 min read
106

Evaluate dependent feature flags consistently within a request

A request reads several feature flags while their configuration changes.

5 min read
107

Publish database changes through a transactional outbox

A service commits an order but crashes before publishing its event.

5 min read
108

Protect a cross-row invariant from write skew

Two operators can independently disable service replicas, but at least one replica must remain enabled.

5 min read
109

Reduce read-tail latency with bounded hedging

A replicated read service has occasional slow replicas.

5 min read
110

Isolate slow dependencies with bulkheads

One optional downstream service consumes every worker and makes unrelated endpoints fail.

5 min read
111

Adapt in-flight limits from latency feedback

A service's safe concurrency changes with request cost.

5 min read
112

Aggregate many downstream reads under one deadline

An endpoint fans out to 100 shards.

5 min read
113

Process leased queue messages without duplicate effects

A task runs longer than its queue visibility timeout and another worker receives it.

5 min read
114

Set a defensible idempotency retention window

An API deduplicates retries for one day.

5 min read
115

Correlate asynchronous callbacks to the right workflow attempt

An external system calls back hours after a workflow task timed out and retried.

5 min read
116

Track email delivery failures and suppression

Build an email-status service that distinguishes send acceptance, delivery, bounce and complaint while avoiding repeated sends to invalid addresses.

5 min read
117

Fetch link previews without trusting arbitrary URLs

A chat app wants titles and thumbnails for user-supplied URLs.

5 min read
118

Emit stable geofence entry and exit events

GPS observations oscillate near a boundary and produce repeated arrival notifications.

5 min read
119

Insert a rider into an existing pooled route

Match a new ride request to vehicles without violating existing riders' capacity, pickup or detour promises.

5 min read
120

Reconcile parking-space occupancy from conflicting sensors

A parking service receives gate counts and per-space sensors that disagree.

5 min read
121

Run an authoritative multiplayer simulation loop

Design a server simulation that receives irregular client inputs while maintaining reproducible game-state progression.

5 min read
122

Publish seasonal rankings with explicit tie rules

Design a leaderboard with tied scores, late score updates and a season-close deadline that users can audit.

5 min read
123

Copy a changing directory tree with a resumable manifest

Move millions of files between stores while failures and source changes occur.

5 min read
124

Recover from missed filesystem watch events

A file-indexing service relies on change notifications, but its event queue overflows.

5 min read
125

Evolve a binary message format safely

Old and new clients exchange serialized messages during a rolling upgrade.

5 min read
126

Enforce purpose-specific consent in asynchronous processing

A user revokes permission while data is queued for an optional analytics job.

5 min read
127

Batch warehouse picks under route and cart constraints

A warehouse wants shorter picking routes without mixing customer orders or overloading carts.

5 min read
128

Verify deployment artifacts against an identity policy

A deployment platform receives a signed container image.

5 min read
129

Roll out an authoritative DNS zone change

Change a service's DNS records across authoritative servers and explain why a successful update does not immediately move every client.

5 min read
130

Propagate backpressure through a streaming pipeline

A producer is faster than a network consumer and memory grows continuously.

5 min read
131

Serve materialized views with an explicit freshness contract

An analytics dashboard reads precomputed results.

5 min read
132

Keep agent tool calls compatible across schema changes

An agent may pause for hours between planning a tool call and executing it. Design a tool registry that survives a breaking schema release without silently changing the requested action.

3 min read
133

Contain prompt injection in a tool-using research agent

A research agent reads public pages and can save notes to an internal workspace. A retrieved page tells it to upload private files. Design the boundary that prevents this instruction from becoming an authorized action.

3 min read
134

Stop an agent that repeats actions without making progress

An agent alternates between searching and reopening the same documents. Design termination controls that bound cost while still allowing useful retries.

3 min read
135

Handle tool results that exceed an agent context budget

A database tool returns a million rows when the agent expected a short answer. Design a result protocol that bounds memory and model context without pretending a partial result is complete.

3 min read
136

Compute useful facet counts without leaking hidden results

A product search offers brand, size and color filters. Design facet counts that show useful alternatives while respecting visibility rules and remaining consistent with the result list.

3 min read
137

Design an adaptive jitter buffer for live speech

Voice packets arrive out of order with variable delay. Design a receiver that smooths playback without adding excessive conversational latency.

3 min read
138

Stop streaming speech cleanly when the user interrupts

A voice assistant generates text and speech ahead of playback. Design barge-in so an interruption stops old audio and prevents late chunks from leaking into the next response.

3 min read
139

Allocate video layers for a constrained conference receiver

A video conference receiver has limited downlink bandwidth while several speakers publish multiple video layers. Design SFU forwarding that preserves audio and adapts without constant quality oscillation.

3 min read
140

Split a hot key range without creating two write owners

A range-partitioned store has one overloaded partition while other servers are idle. Design an online split that preserves acknowledged writes and routes stale clients safely.

3 min read
141

Route reads with an explicit maximum staleness bound

A reporting API may return data at most five seconds old. Design replica routing that enforces this promise during replication lag and primary failover.

3 min read
142

Detect silent storage corruption with a scrub scheduler

A replicated object store rarely reads cold objects. Design periodic integrity scrubbing that detects corruption without overwhelming foreground traffic or repairing from an untrusted copy.

3 min read
143

Protect a hot cache from one-time scans

A dashboard cache works well until a nightly scan reads thousands of unique keys and evicts the hot working set. Design admission control that distinguishes a miss from a reason to retain an item.

3 min read
144

Rename a directory atomically in a distributed namespace

A distributed file service must move a directory to a new parent while clients are creating children and reading paths. Design atomic namespace semantics without copying every file.

3 min read

Two ways to read.

Foundation path

Follow a request through the system.

Begin with the quota contract. Work through the bucket example, then explain why checking and consuming a token must happen atomically.

Experienced path

Make the guarantees explicit.

Focus on regional budget allocation, ambiguous timeouts, failover, and the difference between protective limiting and exact accounting.

Connect it to ML serving.

↗

Freshness and fallbacks in search

Apply the same reasoning about deadlines, state, and degraded behavior to an ML system.

Related walkthrough