Free · 194 cards · spaced repetition

System Design flashcards

Every quick check from the course's lessons and revisions, plus each lesson's interview line and its common mistake. Do a few a day: a card you know comes back later, a card you miss comes back sooner, so it's still there in the interview.

Your cards are loading…

Keys: Space shows the answer, 1 is "Not yet", 2 is "I knew it". Saved on this device only.

All 194 cards

Tap a question to see its answer, and the lesson it comes from.

Week 1: Foundations

If a user has a great internet connection but the DNS server is slow, what happens?

The app will feel 'stuck' or laggy before it even begins to load data, because it can't find the server's IP.

From Lesson 1: What happens when you open an app

What happens when you open an app: what do you say about it in the interview?

A request is a series of hops: DNS for the address, TCP/TLS for the connection, and HTTP for the data.

From Lesson 1: What happens when you open an app

If your average traffic is 1,000 requests per second, what should you design your system to handle?

At least 3,000 requests per second to account for peak usage.

From Lesson 2: The numbers every engineer should know

The numbers every engineer should know: what do you say about it in the interview?

With 1M orders, we expect 10 RPS average and 30 RPS peak, requiring roughly 365GB of storage per year.

From Lesson 2: The numbers every engineer should know

Why is cursor pagination better than offset pagination for a busy app like QuickBite?

It handles new data being added while scrolling without skipping or duplicating items.

From Lesson 3: APIs and data models: the contract of a system

APIs and data models: the contract of a system: what do you say about it in the interview?

I'll start by defining the API endpoints and the data schema to establish a clear contract.

From Lesson 3: APIs and data models: the contract of a system

You've finished the high-level design. What is the very next thing you should do?

Ask the interviewer which part of the system they want to deep-dive into.

From Lesson 4: The 45-minute system design interview

The 45-minute system design interview: what do you say about it in the interview?

I'll start by clarifying requirements and estimating scale so we don't over-engineer the solution.

From Lesson 4: The 45-minute system design interview

Why is the first request to a new server slower than the ones after it?

It pays for the TCP and TLS handshakes first. Later requests reuse the open connection.

From Week 1 revision

Your internet is fast, but the DNS resolver is slow. What does the user see?

Nothing, at first: the app can't reach the server until it knows the address.

From Week 1 revision

Average traffic is 2,000 requests a second. What should you design for?

About 6,000 a second: peaks run around three times the average.

From Week 1 revision

Which is slower: reading from memory, or from an SSD? By how much?

Disk: an SSD read is over a thousand times slower than memory.

From Week 1 revision

A payment request times out and the app retries. How do you avoid charging twice?

Send an idempotency key: the server sees the same key again and does the work only once.

From Week 1 revision

You've drawn the high-level design. What's your next move?

Ask the interviewer which part to deep-dive into, instead of guessing.

From Week 1 revision

Week 2: Scaling

You add a second app server, and users get logged out on their next click. What went wrong?

Sessions lived in one server's memory. Move them to a shared session store.

From Lesson 5: Scaling from one server to many

Peak traffic is 900 requests a second, and each server handles 200. How many servers?

Five to carry the load, plus one spare: six.

From Lesson 5: Scaling from one server to many

Scaling from one server to many: what do you say about it in the interview?

I'll keep the app servers stateless, with sessions in a shared store, so we can scale out behind a load balancer.

From Lesson 5: Scaling from one server to many

Scaling from one server to many: what's the common mistake?

Adding app servers and forgetting the database behind them.

From Lesson 5: Scaling from one server to many

Some QuickBite requests take 50 ms and some take 5 seconds. Round robin or least connections?

Least connections: new work goes to the server with the fewest requests in flight, so slow requests don't pile up on one server.

From Lesson 6: Load balancers

App server 2 crashes at lunch. What do customers notice?

Almost nothing: health checks take it out within seconds, and the other servers take its traffic.

From Lesson 6: Load balancers

Load balancers: what do you say about it in the interview?

A layer 7 load balancer with least connections and health checks, in an active and standby pair.

From Lesson 6: Load balancers

Load balancers: what's the common mistake?

Drawing one load balancer and forgetting it can fail too.

From Lesson 6: Load balancers

Your cache hit rate drops from 95% to 50%. What happens to the database?

It gets ten times the reads: misses go from 5% of reads to 50%.

From Lesson 7: Caching: making reads fast

A restaurant changes a price, but customers see the old one for ten minutes. Why?

Nobody deleted the cached menu on the write, so it stayed until its 10-minute TTL ran out. Delete the key on every write.

From Lesson 7: Caching: making reads fast

Caching: making reads fast: what do you say about it in the interview?

The menu is read-heavy, so I'll add a cache-aside layer in Redis with a TTL; at a 90% hit rate the database sees a tenth of the reads.

From Lesson 7: Caching: making reads fast

Caching: making reads fast: what's the common mistake?

Saying "add a cache" without saying what, how it stays fresh, and the hit rate you expect.

From Lesson 7: Caching: making reads fast

At exactly 1:00 PM, the database CPU jumps to 100%, while the cache looks fine. What happened?

Stampede: a hot key expired, and every request missed at once. Coalesce the refill.

From Lesson 8: Caching at scale: invalidation, hot keys and stampedes

You delete the cache key, then write the database. What can go wrong?

A reader can refill the old value in between, and the cache stays stale until its TTL.

From Lesson 8: Caching at scale: invalidation, hot keys and stampedes

Caching at scale: invalidation, hot keys and stampedes: what do you say about it in the interview?

Write the database, then delete the key; spread hot keys across replicas; and coalesce misses so one expiry can't stampede the database.

From Lesson 8: Caching at scale: invalidation, hot keys and stampedes

Caching at scale: invalidation, hot keys and stampedes: what's the common mistake?

Assuming the cache always helps: a stampede or a hot key can make it the thing that takes you down.

From Lesson 8: Caching at scale: invalidation, hot keys and stampedes

Why is a presigned URL better than uploading through your own server?

Bytes never touch your servers, and the link expires and can cap size and type.

From Lesson 9: CDNs and object storage

A restaurant replaces a photo, but customers keep seeing the old one. What's the fix?

Give the new photo a new file name: the CDN treats it as a new file.

From Lesson 9: CDNs and object storage

CDNs and object storage: what do you say about it in the interview?

Files go to object storage via presigned URLs, metadata goes to the database, and users read through a CDN.

From Lesson 9: CDNs and object storage

CDNs and object storage: what's the common mistake?

Sending uploads through your own app servers, or storing images inside the database.

From Lesson 9: CDNs and object storage

Peak traffic is 900 requests a second; one server handles 200. How many servers?

Six: five to carry the load, plus one spare.

From Week 2 revision

Users get logged out after you add a second server. Why?

Sessions lived in one server's memory. Move them to a shared store.

From Week 2 revision

Requests take anywhere from 50 ms to 5 seconds. Which load balancing method?

Least connections: new requests go to the least busy server.

From Week 2 revision

Your hit rate falls from 95% to 50%. What happens to the database?

Ten times the reads: misses go from 5% to 50%.

From Week 2 revision

At exactly 1 PM the database CPU hits 100%. The cache looks fine. What happened?

A stampede: a hot key expired and every request missed at once.

From Week 2 revision

A restaurant changes a photo, but customers see the old one for days. Fix?

Give the new photo a new file name.

From Week 2 revision

Week 3: Data

An index on (customer_id, created_at). Can "all orders placed today" use it?

No: the query doesn't use customer_id, the first column. Leftmost prefix.

From Lesson 10: Database indexes: how lookups stay fast

A table gets 50,000 writes a second and very few reads. More indexes, or fewer?

Fewer: every index is another write. Or a store built on LSM trees.

From Lesson 10: Database indexes: how lookups stay fast

Database indexes: how lookups stay fast: what do you say about it in the interview?

Index the columns your queries filter and sort by: here, (customer_id, created_at).

From Lesson 10: Database indexes: how lookups stay fast

Database indexes: how lookups stay fast: what's the common mistake?

Drawing a database box with no word about how it will be read.

From Lesson 10: Database indexes: how lookups stay fast

Writes are fine, but reads are overloading the database. What do you add?

Read replicas: followers that copy the leader and take the reads.

From Lesson 11: Replication: copies of your data

A user changes their address, refreshes, and sees the old one. Why, and the fix?

Replica lag. Read the user's own data from the leader for a few seconds after a write.

From Lesson 11: Replication: copies of your data

Replication: copies of your data: what do you say about it in the interview?

Leader-follower, asynchronous, with read replicas; a user's own data read from the leader.

From Lesson 11: Replication: copies of your data

Replication: copies of your data: what's the common mistake?

Adding replicas and forgetting lag: users can't see what they just wrote.

From Lesson 11: Replication: copies of your data

Orders are sharded by customer ID. Which common query gets slow?

Restaurant queries, like tonight's orders: they must ask every shard.

From Lesson 12: Sharding: splitting data across machines

Keys go to shards by hash mod 4. You add a fifth shard. Roughly how many keys move?

About 80%: only 1 key in 5 stays where it was.

From Lesson 12: Sharding: splitting data across machines

Sharding: splitting data across machines: what do you say about it in the interview?

Shard orders by hash of customer ID: even load, and each customer's queries hit one shard.

From Lesson 12: Sharding: splitting data across machines

Sharding: splitting data across machines: what's the common mistake?

Sharding first. Indexes, caches and replicas come before splitting the data.

From Lesson 12: Sharding: splitting data across machines

Ten cache nodes using hash mod N. You add an eleventh. Roughly how many keys move?

About 90%: only 1 key in 11 stays on its node.

From Lesson 13: Consistent hashing

Same ten nodes, on a consistent hashing ring. You add an eleventh. Now?

About 1/11 of the keys, roughly 9%, from its neighbours.

From Lesson 13: Consistent hashing

Consistent hashing: what do you say about it in the interview?

Spread keys with consistent hashing and virtual nodes: adding a node moves only about 1/N of the keys.

From Lesson 13: Consistent hashing

Consistent hashing: what's the common mistake?

Saying "consistent hashing" and stopping: say what moves when a node joins or leaves.

From Lesson 13: Consistent hashing

N = 3, W = 2, R = 1. Does every read see the latest write?

No: R + W = 3, not more than N. The one copy you read may have missed it.

From Lesson 14: CAP, consistency and quorums

The network splits. A payment service can't reach its other copy. Answer or refuse?

Refuse, or wait: for money, consistency beats availability.

From Lesson 14: CAP, consistency and quorums

CAP, consistency and quorums: what do you say about it in the interview?

Strong where money moves, eventual where it doesn't; quorums with R + W > N where you need both.

From Lesson 14: CAP, consistency and quorums

CAP, consistency and quorums: what's the common mistake?

"Pick two of three." Partitions aren't optional: the choice is C or A when the network breaks.

From Lesson 14: CAP, consistency and quorums

An index on (restaurant_id, created_at). Can "restaurant 9's orders tonight" use it?

Yes: it starts with restaurant_id, then reads one time range.

From Week 3 revision

A rider accepts a job, but their app still shows it as open. You use read replicas. Why?

Replica lag: the read hit a follower that hadn't caught up. Read your own writes.

From Week 3 revision

You shard users by signup date. What goes wrong?

A hot shard: every new signup lands on the newest shard.

From Week 3 revision

A 50-node cache on a hash ring loses one node. How much of the cache is gone?

About 1/50 of the keys, 2%; virtual nodes spread its load across the rest.

From Week 3 revision

N = 5 copies and W = 3. What's the smallest R that always sees the latest write?

R = 3, because R + W must be more than 5.

From Week 3 revision

During a network split, the likes counter keeps answering with old numbers. Consistent or available?

Available, and that's the right choice: a stale like count harms no one.

From Week 3 revision

Week 4: Async

A worker sends a text, then crashes before acknowledging. What happens?

Another worker gets the message after the timeout and sends it again: at-least-once.

From Lesson 15: Message queues

One message fails every time, and workers keep retrying it. What's the fix?

Retry with backoff a few times, then move it to a dead-letter queue.

From Lesson 15: Message queues

Message queues: what do you say about it in the interview?

Anything the user needn't wait for goes on a queue: at-least-once, with backoff and a dead-letter queue.

From Lesson 15: Message queues

Message queues: what's the common mistake?

Queueing something the user must wait for, like whether a card payment succeeded.

From Lesson 15: Message queues

A topic has 4 partitions. One consumer group runs 6 workers. How many are busy?

Four: one per partition. The other two sit idle.

From Lesson 16: Kafka and event streaming

Analytics deployed a bug two days ago and counted wrong. How do they fix the numbers?

Fix the bug, rewind the group's offset two days, and replay.

From Lesson 16: Kafka and event streaming

Kafka and event streaming: what do you say about it in the interview?

Publish events to a Kafka topic, partitioned by key for order; each team reads with its own consumer group.

From Lesson 16: Kafka and event streaming

Kafka and event streaming: what's the common mistake?

Expecting global order: Kafka orders events only within a partition.

From Lesson 16: Kafka and event streaming

Which is idempotent: "set points to 50" or "add 50 points"?

Set points to 50: doing it twice gives the same result.

From Lesson 17: Idempotency and exactly-once in practice

A service saves an order, then crashes before publishing its event. What's the fix?

The outbox: save the event in the same transaction, and let a relay publish it.

From Lesson 17: Idempotency and exactly-once in practice

Idempotency and exactly-once in practice: what do you say about it in the interview?

Clients send an idempotency key; consumers dedupe by event ID; events leave through an outbox.

From Lesson 17: Idempotency and exactly-once in practice

Idempotency and exactly-once in practice: what's the common mistake?

Retrying a payment without a key: the retry is a brand-new charge.

From Lesson 17: Idempotency and exactly-once in practice

A match score changes every few minutes, and only flows to viewers. Which approach?

Server-sent events, or simple polling: one-way, rare updates.

From Lesson 18: Real-time updates: polling, SSE and WebSockets

A rider's update reaches one server, but the customer is connected to another. How does it get there?

Pub/sub: the customer's server subscribed to the order's channel.

From Lesson 18: Real-time updates: polling, SSE and WebSockets

Real-time updates: polling, SSE and WebSockets: what do you say about it in the interview?

WebSockets through dedicated connection servers, with pub/sub routing updates to them.

From Lesson 18: Real-time updates: polling, SSE and WebSockets

Real-time updates: polling, SSE and WebSockets: what's the common mistake?

Forgetting that a socket lives on one server: updates need pub/sub to find it.

From Lesson 18: Real-time updates: polling, SSE and WebSockets

A limit of 100 a minute, in fixed windows. What's the most a client can send in 2 seconds?

200: 100 at the end of one minute, and 100 at the start of the next.

From Lesson 19: Rate limiting

A bucket of 10 tokens, refilling 1 a second, is full. 15 requests arrive at once. How many pass?

10: one per token. The other 5 get a 429.

From Lesson 19: Rate limiting

Rate limiting: what do you say about it in the interview?

A token bucket per user or IP, checked at the gateway, counted in Redis; 429 with Retry-After.

From Lesson 19: Rate limiting

Rate limiting: what's the common mistake?

Counting per server: with 10 servers, the real limit is 10 times too high.

From Lesson 19: Rate limiting

Checkout sends the receipt email itself, and slows down whenever email is slow. Fix?

Queue it: put the receipt on a queue and answer the customer straight away.

From Week 4 revision

A Kafka topic has 8 partitions, and a consumer group has 3 workers. How is the work split?

Two or three partitions each: every partition goes to one worker.

From Week 4 revision

The rewards worker receives the same "order placed" event twice. How do you avoid double points?

Record each event ID with the work, and skip IDs already seen.

From Week 4 revision

Why use an outbox, instead of saving the order and then publishing the event?

A crash between the two loses the event; the outbox saves both in one transaction.

From Week 4 revision

Updates flow only from server to browser, every few seconds. WebSockets, or something simpler?

Server-sent events: one-way is all it needs.

From Week 4 revision

Ten gateways each allow 100 requests a minute per user, counted locally. What's the real limit?

Ten times higher: up to 1,000 a minute. Share the counters in Redis.

From Week 4 revision

Week 5: Architecture

Five engineers, one product, a year old. Should they split into microservices?

No: keep a well-organised monolith, and split later when teams or scaling demand it.

From Lesson 20: Microservices, gateways and service discovery

The orders service needs a dish's price. Should it read the menus database directly?

Ask the menus service through its API: each service owns its data.

From Lesson 20: Microservices, gateways and service discovery

Microservices, gateways and service discovery: what do you say about it in the interview?

Split by business capability, each service owning its data, behind an API gateway.

From Lesson 20: Microservices, gateways and service discovery

Microservices, gateways and service discovery: what's the common mistake?

Services that share one database: all the costs, none of the independence.

From Lesson 20: Microservices, gateways and service discovery

Three layers each try 3 times. One failing request becomes how many calls at the bottom?

27: 3 × 3 × 3. Retry at one layer only.

From Lesson 21: When things fail: timeouts, retries and circuit breakers

The provider is down. Calls wait 2 seconds to time out, 500 times a second. What helps most?

A circuit breaker: fail at once, stop calling, and let it recover.

From Lesson 21: When things fail: timeouts, retries and circuit breakers

When things fail: timeouts, retries and circuit breakers: what do you say about it in the interview?

Timeouts on every call, capped retries with jitter, a circuit breaker and a fallback per dependency.

From Lesson 21: When things fail: timeouts, retries and circuit breakers

When things fail: timeouts, retries and circuit breakers: what's the common mistake?

Drawing only the happy path. Interviewers ask what happens when this is slow.

From Lesson 21: When things fail: timeouts, retries and circuit breakers

The card is charged, then the restaurant rejects the order. In a saga, what happens?

Compensate: refund the card, cancel the order, and tell the customer.

From Lesson 22: Distributed transactions: two-phase commit and sagas

Why is two-phase commit risky between services?

Locks are held while waiting, and everyone is stuck if the coordinator dies.

From Lesson 22: Distributed transactions: two-phase commit and sagas

Distributed transactions: two-phase commit and sagas: what do you say about it in the interview?

Across services, a saga: local transactions with compensating steps, run by an orchestrator.

From Lesson 22: Distributed transactions: two-phase commit and sagas

Distributed transactions: two-phase commit and sagas: what's the common mistake?

Assuming one transaction can span several services' databases.

From Lesson 22: Distributed transactions: two-phase commit and sagas

Snowflake has 12 sequence bits. How many IDs can one machine make in one millisecond?

4,096: two to the power twelve.

From Lesson 23: Unique IDs at scale

Why do random UUIDs slow down inserts into a big B-tree index?

Random placement: each new ID lands somewhere new, so inserts scatter instead of appending.

From Lesson 23: Unique IDs at scale

Unique IDs at scale: what do you say about it in the interview?

Snowflake-style 64-bit IDs: time, machine, sequence. Unique without coordination, and sortable.

From Lesson 23: Unique IDs at scale

Unique IDs at scale: what's the common mistake?

Keeping auto-increment IDs after you've sharded.

From Lesson 23: Unique IDs at scale

An SLO of 99.9% a month. How much bad time does the error budget allow?
A trace: 9 s in total; restaurant 0.1 s, rider matching 0.3 s, payments 8.2 s. Where do you look first?

Payments: it holds 8.2 of the 9 seconds.

From Lesson 24: Observability: logs, metrics and traces

Observability: logs, metrics and traces: what do you say about it in the interview?

RED metrics per service, traces carrying an ID through every call, structured logs, and alerts on SLOs.

From Lesson 24: Observability: logs, metrics and traces

Observability: logs, metrics and traces: what's the common mistake?

Saying "add monitoring" with no numbers: name the metrics and the SLO.

From Lesson 24: Observability: logs, metrics and traces

Two services share one database. What's the problem?

Every schema change by one team can break the other: no independence.

From Week 5 revision

A provider's p99 is 1 second. What timeout would you set?

About 2 seconds: just above the normal slowest, never 30.

From Week 5 revision

Why add jitter to retries?

So clients that failed together don't all retry at the same moment.

From Week 5 revision

In a saga, which goes last: charging the card, or the kitchen starting to cook?

Cooking: it can't be undone, while a charge can be refunded.

From Week 5 revision

Snowflake gives 10 bits to the machine ID. How many generators can run at once?

1,024: two to the power ten.

From Week 5 revision

An alert fires whenever CPU passes 80%, though users are fine. Good alert?

No: alert on symptoms users feel, like errors and latency.

From Week 5 revision

Week 6: Patterns

A restaurant with 2,000 followers posts a new dish. Push, or pull?

Push: 2,000 writes is cheap, and every follower's read stays instant.

From Lesson 25: News feeds: fan-out on write or on read

A chain with 5 million followers posts an offer. How do followers see it?

Pull: its recent posts are merged in when each follower's feed is read.

From Lesson 25: News feeds: fan-out on write or on read

News feeds: fan-out on write or on read: what do you say about it in the interview?

Hybrid fan-out: push into followers' feed caches, pull for celebrities, merged at read time.

From Lesson 25: News feeds: fan-out on write or on read

News feeds: fan-out on write or on read: what's the common mistake?

Choosing push or pull. Interviewers want the hybrid, and why.

From Lesson 25: News feeds: fan-out on write or on read

Why can't a B-tree index speed up LIKE '%paneer%'?

Because the word can be anywhere in the text; a sorted index only helps with the start.

From Lesson 26: Search: inverted indexes and typeahead

paneer → 12, 87, 203 and pizza → 87, 99. Which dish matches "paneer pizza"?

Dish 87: the only one in both lists.

From Lesson 26: Search: inverted indexes and typeahead

Search: inverted indexes and typeahead: what do you say about it in the interview?

Search in Elasticsearch: an inverted index, sharded and replicated, kept in sync by CDC.

From Lesson 26: Search: inverted indexes and typeahead

Search: inverted indexes and typeahead: what's the common mistake?

Treating the search index as the source of truth: it's a copy, rebuilt from the database.

From Lesson 26: Search: inverted indexes and typeahead

300,000 riders each send a position every 4 seconds. How many updates a second?
Why search the 8 neighbouring cells, not just the restaurant's own?

Because a nearby rider can sit just across a cell boundary, in a different cell.

From Lesson 27: Geospatial: finding what's nearby

Geospatial: finding what's nearby: what do you say about it in the interview?

Geohash or H3 cells, in memory; search the cell and its neighbours, then filter by real distance.

From Lesson 27: Geospatial: finding what's nearby

Geospatial: finding what's nearby: what's the common mistake?

Searching one cell, and missing the rider just across the line.

From Lesson 27: Geospatial: finding what's nearby

Two requests each read an order, see it's free, and assign their rider. What's wrong?

A race: both saw "free" before either wrote. Use a conditional write or a lock.

From Lesson 28: Contention: two people, one seat

An UPDATE … WHERE version = 7 changes 0 rows. What does that mean?

Someone else changed it first: re-read it, and decide again.

From Lesson 28: Contention: two people, one seat

Contention: two people, one seat: what do you say about it in the interview?

A conditional write or version check for quick races; holds with an expiry for slow ones.

From Lesson 28: Contention: two people, one seat

Contention: two people, one seat: what's the common mistake?

Read, then write, with no condition: the classic race.

From Lesson 28: Contention: two people, one seat

A 2 GB file is sent in 10 MB parts. How many parts, and what's resent if one fails?

About 200 parts; only the failed 10 MB part is resent.

From Lesson 29: Big files and long jobs

Jobs take 10 minutes, but the queue's visibility timeout is 30 seconds. What happens?

Duplicates: the job reappears while running, and another worker starts it too.

From Lesson 29: Big files and long jobs

Big files and long jobs: what do you say about it in the interview?

Multipart, resumable uploads straight to storage; processing as jobs on a queue, with progress and checkpoints.

From Lesson 29: Big files and long jobs

Big files and long jobs: what's the common mistake?

Sending big files through your servers, or processing them inside the request.

From Lesson 29: Big files and long jobs

A customer follows 300 normal restaurants and 2 huge chains. How is their feed built?

Read their pushed list, then merge in the two chains' recent posts.

From Week 6 revision

Why feed the search index with change data capture?

Every database change reaches the index, without the app writing twice.

From Week 6 revision

Cells are 5 km wide, but you search 500 metres around a restaurant. What's the problem?

Too many riders per cell to filter: use smaller cells.

From Week 6 revision

Give the one-line fix for two riders accepting the same order.

UPDATE orders SET rider = ? WHERE id = 421 AND rider IS NULL.

From Week 6 revision

A customer holds a festival thali, then closes the app. What happens to it?

Nothing at first; when the hold expires, the thali goes back on offer.

From Week 6 revision

A 2 GB upload drops at part 150 of 200. What does a resumable upload do?

Continue from part 150: the first 149 parts are already stored.

From Week 6 revision

Week 7: Case studies

A viewer's network drops from 20 to 2 Mbps mid-video. What happens?

Lower quality from the next segment: the player switches down instead of stalling.

From Lesson 30: Design YouTube: upload, transcode, stream

Why cut a video into segments before transcoding it?

Parallel work: many workers transcode small pieces at once, so long videos finish in minutes.

From Lesson 30: Design YouTube: upload, transcode, stream

Design YouTube: upload, transcode, stream: what do you say about it in the interview?

Resumable uploads to storage, segment-parallel transcoding, adaptive streaming, served from a CDN.

From Lesson 30: Design YouTube: upload, transcode, stream

Design YouTube: upload, transcode, stream: what's the common mistake?

Serving video from your own servers, or one single file for every device.

From Lesson 30: Design YouTube: upload, transcode, stream

You fix a typo in a 200 MB file, changing one 4 MB block. How much is uploaded?

Just that one block, about 4 MB, plus a small metadata commit.

From Lesson 31: Design Dropbox: files in sync everywhere

Two laptops edit the same file offline, then reconnect. What happens to the second commit?

Both versions are kept: the second becomes a conflicted copy.

From Lesson 31: Design Dropbox: files in sync everywhere

Design Dropbox: files in sync everywhere: what do you say about it in the interview?

Files as lists of content-hashed blocks; metadata in a consistent DB, blocks in object storage.

From Lesson 31: Design Dropbox: files in sync everywhere

Design Dropbox: files in sync everywhere: what's the common mistake?

Re-uploading whole files on every change, or keeping files in the database.

From Lesson 31: Design Dropbox: files in sync everywhere

Why does the frontier keep one queue per website?

Politeness: each site gets one request at a time, with a pause between them.

From Lesson 32: Design a web crawler

The Bloom filter says "probably seen" for a URL it has never seen. What's the cost?

One page skipped this time: a small, acceptable loss.

From Lesson 32: Design a web crawler

Design a web crawler: what do you say about it in the interview?

A prioritised frontier with one queue per host, sharded by host; Bloom filters and content hashes to dedupe.

From Lesson 32: Design a web crawler

Design a web crawler: what's the common mistake?

One big FIFO queue: a single busy website gets hammered, and important pages wait behind junk.

From Lesson 32: Design a web crawler

Why store the top 10 completions at every trie node?

So each request is one lookup: no walking the subtree or ranking while the user types.

From Lesson 33: Design search autocomplete

A news event makes a new query explode, but the trie rebuilds once a day. What's the fix?

A trending layer, updated every few minutes, merged with the trie's results.

From Lesson 33: Design search autocomplete

Design search autocomplete: what do you say about it in the interview?

A trie with the top 10 at every node, built offline from query logs, served from memory.

From Lesson 33: Design search autocomplete

Design search autocomplete: what's the common mistake?

Searching and ranking at request time, instead of precomputing the answers.

From Lesson 33: Design search autocomplete

The SMS gateway slows down. Do push notifications slow down too?

No: each channel has its own queue and workers.

From Lesson 34: Design a notification system

The "rider assigned" event arrives twice. How does the customer get only one push?

Dedupe on the event ID, user and type before sending.

From Lesson 34: Design a notification system

Design a notification system: what do you say about it in the interview?

Events in, preferences and templates, a queue per channel, dedupe and retries, and two priority lanes.

From Lesson 34: Design a notification system

Design a notification system: what's the common mistake?

One shared queue: a big marketing blast delays one-time passwords.

From Lesson 34: Design a notification system

What does a video player use to choose the quality of its next segment?

Its measured download speed for the last few segments.

From Week 7 revision

You copy a 5 GB folder to a new place inside Dropbox. How much is uploaded?

Almost nothing: every block's hash is already stored.

From Week 7 revision

Why shard the crawler's frontier by website?

Each site lives on one machine, so politeness is a local decision.

From Week 7 revision

A calendar page links to "next month" forever. What protects the crawler?

Limits on depth and pages per site: it's a crawler trap.

From Week 7 revision

Why build the autocomplete trie offline, instead of on each request?

Building is heavy; serving must be a fast lookup, so do the work once, ahead of time.

From Week 7 revision

A sale goes out to 50 million users. How do one-time passwords stay fast?

Separate transactional queues: they never wait behind marketing.

From Week 7 revision

Week 8: Senior level

The text is "cat". Ben inserts "the " at 0, then Ana's "s" at 3 arrives. Where does the s go?

Position 7: shifted by Ben's 4 characters, giving "the cats".

From Lesson 35: Design Google Docs: editing together in real time

Why route every editor of one document to the same server?

One place orders that document's edits, and keeps it in memory.

From Lesson 35: Design Google Docs: editing together in real time

Design Google Docs: editing together in real time: what do you say about it in the interview?

OT (or a CRDT), one session server per document, edits logged before broadcast, snapshots for loading.

From Lesson 35: Design Google Docs: editing together in real time

Design Google Docs: editing together in real time: what's the common mistake?

"Last write wins" on a shared document: characters vanish.

From Lesson 35: Design Google Docs: editing together in real time

A paused worker's lease expired, and another worker reran the job. What stops double payouts?

Idempotent jobs: a payout key per restaurant and date, plus fencing tokens.

From Lesson 36: Design a distributed job scheduler

Ten million jobs are all scheduled for exactly midnight. What's the problem, and the fix?

A spike at 00:00: spread jobs that don't need an exact time.

From Lesson 36: Design a distributed job scheduler

Design a distributed job scheduler: what do you say about it in the interview?

Jobs and runs in a database, runs claimed with a lease, idempotent jobs, priorities and quotas.

From Lesson 36: Design a distributed job scheduler

Design a distributed job scheduler: what's the common mistake?

Promising exactly-once runs: leases and pauses make duplicates possible.

From Lesson 36: Design a distributed job scheduler

A click happened at 12:03:58 but arrived at 12:05:10. Which minute is it counted in?

12:03: count by event time, not arrival time.

From Lesson 37: Stream processing: an ad-click aggregator

The stream processor crashes and restarts. Why aren't clicks counted twice?

Checkpoints: counters and Kafka offsets are restored to the same moment, then replayed.

From Lesson 37: Stream processing: an ad-click aggregator

Stream processing: an ad-click aggregator: what do you say about it in the interview?

Clicks into Kafka, counted in windows by a stream processor, with checkpoints, watermarks, and a nightly recount.

From Lesson 37: Stream processing: an ad-click aggregator

Stream processing: an ad-click aggregator: what's the common mistake?

Counting with database increments per click, and no raw events to recount from.

From Lesson 37: Stream processing: an ad-click aggregator

Why give every customer a home region?

Their data is written in one place, so regions never conflict over it.

From Lesson 38: Multi-region systems

Mumbai fails. Its data was copied to Dubai asynchronously. What might be lost?

Recent writes not yet copied: the last few seconds.

From Lesson 38: Multi-region systems

Multi-region systems: what do you say about it in the interview?

Active-active with a home region per user, geo DNS, async copies, and practised failover.

From Lesson 38: Multi-region systems

Multi-region systems: what's the common mistake?

"Just add another region": without a plan for who writes what, regions conflict.

From Lesson 38: Multi-region systems

The interviewer asks: why Kafka? What makes an answer senior?

A reason tied to the requirements, and a cost: replay for three teams, at the price of running Kafka.

From Lesson 39: Thinking like a senior engineer

Ten minutes left, and you haven't discussed failures. What do you do?

Name the weak spots yourself: what fails, how you'd notice, and how you'd fix it.

From Lesson 39: Thinking like a senior engineer

Why can't a shared document be saved with last write wins?

Each save would erase other people's typing: edits must be merged, not replaced.

From Week 8 revision

A worker's lease runs out while it's still running a job. What can happen?

Another worker claims it and runs it too: a duplicate run.

From Week 8 revision

In stream processing, what is a watermark?

An estimate that all events up to a certain time have arrived; windows close behind it.

From Week 8 revision

Why recount ad clicks every night if the stream already counts them?

Billing needs exact numbers: dedupe, remove bots, and catch what the stream missed.

From Week 8 revision

Why not copy data between regions synchronously?

Every write would wait for a round trip to the far region.

From Week 8 revision

What two things should every box on your diagram have?

A reason it's there, and a cost you can name.

From Week 8 revision