Skip to content

Lesson 1 of 38Building blocks

What Is System Design

Learn what system design means, the requirements that drive it, and the framework interviewers expect you to follow.

22 min read0/9 questions

Writing a function that works is one skill. Deciding how a product with ten million users stores its data, survives a server dying at 3 a.m., and answers in under a fifth of a second is a different one. That second skill is system design, and it is what separates mid-level from senior engineers in both real jobs and interviews. If you took the Design & Architecture course, you have been shaping the code inside one service. This course zooms out to the machines, networks, and data stores that service runs on.

Boxes, arrows, and trade-offs

System design is choosing the parts of a system (servers, databases, caches, queues, CDNs) and how they talk to each other, so the whole thing meets its goals. You draw it as boxes and arrows. The interesting part is never the boxes themselves: it is why each box is there and what it costs you.

Almost every real system starts as one box and grows. Step through how a typical web app evolves as traffic rises.

A web app growing from one box
UsersUsersCDN: images, JSCDNimages, JSLoad balancerLoad balancerApp server 1App server 1App server 2App server 2Cache: RedisCacheRedisPrimary DB: PostgresPrimary DBPostgresRead replicaRead replicastaticHTTPSSQLreadsreplicate

Day one: one server runs your code and the database. This is fine for thousands of users, and you should not build more until you need it.

1/7

Each step fixed a specific problem and added a new one: more servers mean you cannot keep login sessions in one server's memory, a cache can serve stale data, and a replica can lag behind the primary. That pattern (fix a bottleneck, pay with complexity) is the heart of the subject. The rest of this unit teaches each box in detail.

Functional and non-functional requirements

Before drawing anything, you pin down what the system must do. Requirements come in two kinds.

  • Functional requirements are features: what the system does. "Users can post a photo." "Users see a feed of people they follow."
  • Non-functional requirements are qualities: how well it does it. "The feed loads in under 200 ms at the 99th percentile." "We never lose a payment." "It stays up during a data center outage."

Functional requirements decide your API and data model. Non-functional requirements decide your architecture. Two apps with identical features (a chat app for a 10-person team and one for 500 million people) end up with completely different designs because the non-functional requirements differ.

Match the pairs0/4 matched

Match each requirement to its kind.

Choose an item, then its match on the other side.

Scalability and availability

Scalability is the ability to handle more load by adding resources. You scale vertically by buying a bigger machine (more CPU, more RAM) or horizontally by adding more machines. Vertical is simpler but has a ceiling and a single point of failure. Horizontal has no real ceiling but forces you to deal with many machines agreeing on things.

Availability is the fraction of time the system works. It is quoted in "nines".

AvailabilityDowntime per yearDowntime per monthTypical for
99% (two nines)3.65 days7.3 hoursInternal tools
99.9% (three nines)8.8 hours43.8 minutesMost SaaS products
99.99% (four nines)52.6 minutes4.4 minutesPayments, core APIs
99.999% (five nines)5.3 minutes26 secondsTelecoms, cloud control planes

Each extra nine is ten times less downtime and usually much more than ten times the cost. You get there with redundancy: no single machine, rack, or data center whose failure takes everything down. A component like that is a single point of failure (SPOF).

There is a catch when components depend on each other in a chain. If a request must pass through two services and each is up 99.9% of the time, the request succeeds only when both are up.

Predict the outputPython

Two services in a chain, each 99.9% available. What is the combined availability (as a percent)?

a = 0.999
b = 0.999
print(round(a * b * 100, 2))
Need a nudge? Hints walk you through it.

Latency and throughput

Latency is how long one request takes, usually in milliseconds. Throughput is how many requests the system completes per unit of time, usually in QPS (queries per second) or RPS (requests per second).

They are related but not the same. A highway has a speed limit (latency for one car) and a number of lanes (throughput). Adding lanes does not make any single car faster. Likewise, adding servers raises throughput but does nothing for a request that is slow because it waits 80 ms on a database query.

Latency is reported in percentiles, not averages. p50 is the median request. p99 is the request slower than 99% of all others. If your p50 is 40 ms and your p99 is 2 seconds, one user in a hundred is having a terrible time, and a page that makes 20 backend calls will hit that slow tail often.

Quick check
Your API handles 2,000 QPS fine, but every request takes 900 ms because of one slow SQL query. You add four more app servers. What happens?
Need a nudge? A hint rules out a wrong answer.

Durability is not availability

Scale, latency and uptime get most of the attention, but they are not the only qualities that shape a design. The next one people blur is durability.

Availability asks: can I use the system right now? Durability asks: does my data still exist? They fail independently. A database that is down for an hour but loses nothing had bad availability and perfect durability. A database that fails over in ten seconds but quietly drops the last few seconds of writes had great availability and broken durability. For a photo app the second outage is a shrug. For a bank it is a regulator's letter.

Two numbers make durability concrete, and senior engineers use them in every conversation about data:

  • RPO (recovery point objective): how much data you can afford to lose, measured in time. "RPO of 5 minutes" means after a disaster you may lose up to the last 5 minutes of writes.
  • RTO (recovery time objective): how long until the service works again.

Your RPO decides one specific moment in the design: when you tell the client "saved". If you acknowledge a write as soon as the primary has it, and the primary dies before the replica copied it, that write is gone even though the user saw a success. Getting RPO to zero means waiting for a second machine (ideally in another availability zone) to confirm the write before you reply. That costs latency on every write, because each write now waits for a network round trip.

How data is protectedTypical RPOCost you pay
Nightly backup onlyUp to 24 hoursCheap; a bad day loses a day
Point-in-time recovery (archived write-ahead log)Minutes or lessStorage for the log archive
Async replicaSeconds (the replication lag)Recent writes lost on failover
Sync replica in another zoneZero for single failuresSlower writes; a slow replica slows everyone

There is one more trap. Replication protects you from hardware failure, not from mistakes. A buggy migration or a DELETE without a WHERE clause is copied to every replica within milliseconds. Only backups and point-in-time recovery let you go back to before the mistake. And a backup you have never restored is a hope, not a backup: teams that take durability seriously run restore drills on a schedule and time them, because that measured time is their real RTO.

Quick check
A payments service must never lose a payment it has confirmed to the user. The database has a primary and an async replica. What is the weak point?
Need a nudge? A hint rules out a wrong answer.

Security, cost, and operability are requirements too

Three more qualities rarely appear in the prompt, but strong candidates bring them up and real design reviews always ask about them.

Security. Who can call this, and who can see what? Name where authentication happens (usually at the gateway), how authorization is checked (every request checks that this user may touch this resource, not just that they are logged in), and which data is sensitive. A classic hole: object ids that are guessable integers plus a missing ownership check, so GET /invoices/1002 returns someone else's invoice. Also say what you encrypt in transit (everything, with TLS) and at rest, and what you do not store at all. Data you never collect cannot leak.

Cost. A design that meets every target but costs ten times the budget has failed. You do not need prices in an interview, but you should know what drives the bill: bytes stored and for how long, bytes sent out to the internet (egress), compute running around the clock for a peak that happens one hour a day, and per-request charges on managed services. Good cost moves sound like: "We keep raw events for 30 days and aggregates forever", "Images are served from a CDN so the origin egress is small", "Batch jobs run on cheaper interruptible capacity".

Operability. Can a tired engineer at 3 a.m. tell what is broken and fix it? That means metrics, logs and traces that answer real questions, alerts tied to user impact rather than CPU graphs, a deploy that can be rolled back in minutes, and feature flags to turn off a bad path without a deploy. Every new component (a second database, a stream processor, a service mesh) is another thing someone must upgrade, monitor and understand. That is why experienced engineers pick boring, well-understood tools unless a requirement forces something else. The observability and SLOs and reliability patterns lessons go deep on this.

Two more come up in specific domains: compliance (data residency rules such as keeping EU users' data in the EU, and the right to have personal data deleted) and consistency (whether a user may ever see stale data), which has its own lesson in this course.

Match the pairs0/5 matched

Match each design decision to the non-functional requirement it mainly serves.

Choose an item, then its match on the other side.

Write requirements as numbers

"Fast", "reliable" and "scalable" are not requirements. Nobody can design against them or check them later. A senior engineer turns each one into a number with a unit, a percentile, and a place it is measured.

VaguePrecise
The feed should be fastp99 latency of GET /feed under 300 ms, measured at the load balancer
It should be reliable99.9% of requests succeed over a rolling 30 days
It should scale20,000 reads per second at peak, 5x headroom for launches
Do not lose dataRPO 0 for orders, RPO 1 hour for analytics events

Once availability is a number, it becomes a budget. A 99.9% target over a month allows about 43 minutes of full downtime, or the equivalent in failed requests. That budget is what you spend on risky deploys and planned maintenance. Run the numbers for a service that handles 50 million requests a month.

Pythonerror_budget.py
MINUTES_PER_MONTH = 30.44 * 24 * 60 # average monthREQUESTS_PER_MONTH = 50_000_000 for target in [0.99, 0.999, 0.9999]: down_min = MINUTES_PER_MONTH * (1 - target) bad_requests = REQUESTS_PER_MONTH * (1 - target) print(f"{target:.2%} downtime budget {down_min:6.1f} min/month" f" failed-request budget {bad_requests:>9,.0f}")
Output
Press Run (⌘ Enter) to see what happens.

Notice the shape: each extra nine divides the budget by ten. At 99.99% you get about 4 minutes a month, which is less time than it takes a human to be paged, wake up and log in. That is why four nines needs automated failover, not people.

Predict the outputPython

A service gets 50,000,000 requests a month with a 99.9% success target. How many requests may fail before the budget is gone?

print(round(50_000_000 * (1 - 0.999)))
Need a nudge? Hints walk you through it.

The interview framework

System design interviews are open-ended on purpose ("Design Instagram"). Strong candidates follow a structure so they never freeze and never skip what matters. In a 45-minute round it looks like this.

The system design interview, top to bottom
  1. 1. Clarify requirementsFunctional + non-functional, scope, users. ~5 min
  2. 2. EstimateQPS, storage, bandwidth, read/write ratio. ~3 min
  3. 3. APIThe endpoints and their inputs and outputs. ~3 min
  4. 4. Data modelEntities, keys, which database. ~5 min
  5. 5. High-level designBoxes and arrows for the main flows. ~10 min
  6. 6. Deep divesThe hardest parts in detail. ~12 min
  7. 7. Bottlenecks and trade-offsWhat breaks first, what you would change. ~5 min

Never start drawing before you know what you are building. Ask: who uses it, which features are in scope, how many users, what matters most (speed, consistency, cost)?

1/4
Put it in order6 steps

Put the interview steps in order.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.
Quick check
The interviewer says: 'Design a URL shortener.' What is the best first thing to say?
Need a nudge? A hint rules out a wrong answer.

Which deep dive will the interviewer pick

The deep-dive slot is where senior candidates separate themselves, and it is more predictable than it looks. Each classic prompt hides one or two hard problems, and the interviewer usually chose the prompt because of those problems. If you spot them in the first five minutes, you can steer your time there instead of polishing the parts that are easy.

Signal in the promptThe hard part they will probeWhere this course covers it
Money, bookings, "never double charge"Idempotency, transactions across services, retriesPayments, Distributed transactions
Limited stock, seats, flash salesContention on a few hot rows, holds that expireTicketing
Celebrities, followers, a feedFan-out on write vs read, hot keysNews feed, Replication and sharding
Short codes, ids, "unique"Generating ids without a single counterUnique ID generation, URL shortener
Counting clicks, views, metricsStreaming aggregation, late events, deduplicationStream processing, Ad click aggregation
Search, autocomplete, "find"Inverted indexes, ranking, index freshnessSearch and inverted indexes, Search autocomplete
Large files, video, syncChunked uploads, deduplication, CDN deliveryStorage and blobs, File sync, Video streaming
Real time, live location, chatLong-lived connections, presence, geo lookupChat app, Ride sharing
"Survive a region outage", leadersFailover, consensus, split brainMulti-region and DR, Consensus and leader election
Public API, abuse, quotasDistributed counters, fail open vs closedRate limiting

You can also name the deep dives yourself once the high-level design is up: "The two parts I think are hardest here are holding seats during checkout and absorbing the on-sale spike. Which would you like me to go into?" That shows you know where the risk is, and it lets the interviewer steer without having to drag you there.

Quick check
The prompt is 'Design a concert ticket booking site.' You have 12 minutes for deep dives. Which topic is the interviewer most likely to care about?
Need a nudge? A hint rules out a wrong answer.

How this course is laid out

  • Building blocks: estimation, DNS and CDNs, load balancers, caches, databases, replication, consistency, queues, APIs, rate limits, and blob storage.
  • Data internals: how databases lay data out on disk, and how to generate unique IDs without a central counter.
  • Distributed systems: consensus, transactions that span services, and Kafka-style streams.
  • Running in production: SLOs, timeouts and retries, multi-region recovery, and search.
  • Case studies: sixteen full designs, from a URL shortener up to a Ticketmaster on-sale, each using the blocks above.

By the end you can take a vague prompt, turn it into numbers, draw a design that meets them, and defend its trade-offs. The course closes with a wrap-up that walks one design end to end.

Key terms
functional requirement
A feature the system must provide, like 'users can post a photo'.
non-functional requirement
A quality target such as latency, availability, scalability, durability or cost.
availability (nines)
Fraction of time the system works. 99.9% allows about 8.8 hours of downtime a year.
single point of failure
A component whose failure takes the whole system down. Removed with redundancy.
latency vs throughput
Latency is how long one request takes; throughput is how many requests finish per second (QPS).
p99
The latency that 99% of requests beat. It shows the slow tail that averages hide.
durability
The guarantee that acknowledged data survives failures. Separate from availability, which is about being usable right now.
RPO and RTO
Recovery point objective (how much data you may lose, in time) and recovery time objective (how long until service is back).
error budget
The failure allowed by an availability target, such as about 43 minutes a month at 99.9%, spent on risky changes.