Skip to content
learn
  1. Learn
  2. High Level System Design
  3. Orientation

System Design HLD-00.01

What is system design?

What a system is, how high level design differs from code design, and why the same app needs a different shape at 100 users and at 100 million.

Beginner 8 min Last reviewed

The big idea

When you tap "like" on a photo, the tap travels from your phone across the internet to a computer you will never see, which checks who you are, records the like somewhere safe, and tells your phone it worked. Everything between your tap and the data that answers it is the systemAll the parts that work together to serve users: clients, servers, databases, caches, queues and the network connecting them..

System design is deciding what that system looks like. Which boxes exist? What is each one responsible for? How does a request flow through them, and what happens when one of them breaks? These choices matter more than any single line of code, because a well-written program in the wrong architecture still falls over.

A useful picture is a restaurant. A food truck with one cook works perfectly for 30 customers an hour. At 3,000 customers an hour you do not need a faster cook; you need a different restaurant: a host at the door, many cooks, a prep kitchen, a storeroom and a way to keep going when one cook calls in sick. Software grows the same way.

How it works

Step 1: The parts of every system

Almost every web or mobile product is built from the same small set of pieces:

  • Clients: the browser or app the user holds. They send requests and show results.
  • Servers: computers running your application code. They receive requests, apply the rules of your product and build responses.
  • Data stores: databases that keep data safely on disk, and cachesA fast store, usually in memory, holding copies of data that is read often so it does not have to be fetched or computed again. that keep hot copies in memory.
  • The network: everything carrying bytes between them, with delays and failures of its own.

As the system grows, more specialized pieces join: load balancers, queues, CDNs, search indexes. You will meet each one in its own lesson.

Step 2: High level versus low level design

High level designDeciding the components of a system, their responsibilities and how data flows between them. Also called architecture. draws the boxes and arrows: "requests go through a load balancer to stateless app servers, which read from a cache in front of a database". Low level designDesigning the code inside one component: classes, functions, data structures and interfaces. is about what happens inside one box: the classes, functions and data structures. This track is about the first. A good high level design makes the low level work easier, because each box has one clear job.

Step 3: Scale changes the answer

The same app needs a different design at different sizes. Here is a tiny app and the same app grown up:

The same app at 100 users and at 100 million users Left: one user talks to one server, which talks to one database. Right: users reach a CDN and a load balancer, which spreads requests over several app servers; these read from a cache and a primary database with replicas, and push slow work to a queue drained by workers. 100 users 100 million users User Server Database Users CDN images, video Load balancer App App App Cache Primary DB Replicas Queue Figure 1. Left, the whole app on two boxes. Right, the same app after growth: every new box exists because some part of the small design broke under load. The glowing path is one request.

Nothing on the right is there for decoration. The load balancer exists because one server ran out of CPU and could not be allowed to be a single point of failure. The cache exists because the database could not answer the same popular query thousands of times a second. The queue exists because sending emails inside a request made users wait. Every box is the answer to a specific problem that appeared at a specific scale.

Step 4: Every choice is a trade-off

Each box you add buys something and costs something. The three forces you balance on almost every decision are:

  • Performance: how fast each request is and how many you can handle.
  • Reliability: whether the system keeps working, and keeps data safe, when parts fail.
  • Cost: the money for machines and the engineering time to build and run them.

A cache makes reads fast but can serve slightly stale data and is one more thing to operate. A second data center makes you survive disasters but doubles the bill. There are no free wins, only choices that fit the product's needs. That is why designers start every design by asking about requirements.

Try it

This interactive needs JavaScript. The diagrams and text above cover the same idea.

Try this:

  1. Start at 10 users. Notice how little is needed: one machine does everything.
  2. Step to 10,000 users. Two things appear at once. Read the note: which problem does each one solve?
  3. Go all the way to 100 million and walk back down. For each component, say out loud what would break if you removed it.

Going deeper

Requirements come first

Before drawing anything, designers pin down functional requirementsWhat the system must do: its features, such as post a photo or send a message. (what the product does) and non-functional requirementsHow well the system must do it: scale, latency, availability, consistency, cost and so on. (how fast, how available, how consistent, at what scale). A chat app where messages may arrive a second late and a payment system where a lost write is a lawsuit need very different designs even if the boxes look similar. You will practise this in Back-of-the-envelope estimation and the trade-offs map in The core trade-offs map .

Do not build the big version first

The right design is the simplest one that meets today's requirements with room to grow by roughly ten times. Building the 100 million user architecture for a product with 100 users wastes months and adds failure modes you do not need. Good teams grow the design when measurements say a part is close to its limit.

Trade-offs

OptionWins whenLoses when
One server, one database Early products: cheap, simple, easy to debug and deploy Growth beyond one machine, or any need to survive a machine failure
Load-balanced app servers with a cache Most growing products: handles big read traffic and single server failures Very large write volumes or data that no longer fits on one database
Sharded, multi-region architecture Huge global scale and surviving the loss of a whole region Small teams and products: high cost and complexity for problems you do not have yet

Common mistakes

  • Starting with boxes instead of requirements. You cannot judge a design without knowing what it has to achieve.
  • Designing for a scale you will not reach for years. Complexity is a cost you pay every day.
  • Adding a component without being able to say which problem it solves. "Everyone uses Kafka" is not a reason.
  • Forgetting that every box can fail. Asking "what happens when this dies?" for each box is half of system design.

In the wild

Google

Site Reliability Engineering: Introduction (opens in a new tab)

The opening chapter of Google's SRE book explains how Google runs its services. Its central point is that reliability is a design choice with a price: "100% is the wrong reliability target for basically everything," because users cannot tell the difference and every extra nine slows down new features. Teams agree an availability target and treat the gap below 100 percent as an error budget to spend on shipping. It also notes that roughly 70 percent of outages are caused by changes, which is why progressive rollouts and fast rollback are built into the system rather than left to luck.

Check yourself

  1. Which of these is a high level design decision?

    Show answer

    B. Putting a cache in front of the database Deciding which components exist and how data flows between them is high level design. The others are about code inside one component.

  2. Why does a design that works for 100 users often fail at 100 million?

    Show answer

    B. Each jump in scale breaks an assumption, such as one machine being enough One machine, one database, one region: each assumption holds at small scale and breaks at some larger one, so new components are added.

  3. Which three forces are traded off in almost every design decision?

    Show answer

    B. Performance, reliability and cost Faster, more reliable or cheaper: improving one usually costs another.

  4. A team with 200 users plans a sharded, multi-region design. What is the main problem?

    Show answer

    B. It adds cost and complexity for problems they do not have Design for today's needs with room to grow about ten times, and evolve as measurements demand.

Recap

  • A system is everything between a user's action and the data that answers it.
  • High level design picks the components and data flow; low level design is the code inside each one.
  • Each order of magnitude of growth breaks an assumption and adds a component that solves it.
  • Every choice trades performance, reliability and cost against each other.
  • Start from requirements, and build the simplest design that meets them with room to grow.

Get new lessons by email

Get new posts on backend and AI internals. No spam, unsubscribe anytime.

Your email is only used to send new posts. Privacy

Next up