← Back to the map

Unit 0 · Lesson 3

The client–server model

You tap "Like" on a photo. Within a blink, a friend on another continent sees the heart. Where did that like actually go?

By the end you can

Watch

Prefer reading? The same lesson is written out below.

Almost every system you will design in this course has the same basic shape: lots of clients talking to a smaller number of servers.

Two roles, one conversation

A client is whatever starts the conversation. It's the app on your phone, a browser tab, or even another program. A client asks.

A server is a program that waits for requests and answers them. It answers. It usually lives on a machine in a data center, running all day, and it talks to the things clients shouldn't touch directly, like the database.

HTTPPhone appBrowserInternetServerDatabase
A phone and a laptop (clients) send requests across the internet to one server, which reads and writes a database and sends responses back.

The words describe a role, not a type of computer. Your laptop is a client when it loads a web page, and the server that answered it may itself act as a client when it calls a payment provider.

The trip of one request

When you tap "Like":

  1. Your app builds a request: "user 42 likes photo 9001".
  2. It finds the server. A name like api.example.com is turned into an address (that's DNS, in the next unit).
  3. The request travels over the network to that address.
  4. The server checks it: are you logged in? Does the photo exist? Have you already liked it?
  5. The server updates the database and builds a response: "OK, the photo now has 1,204 likes".
  6. The response travels back, and your app turns the heart red.

Each step takes time. Steps 3 and 6 (the network) are often the slowest part, which is why latency will come up again and again in this course.

Why keep the important stuff on the server?

Putting data and rules on the server has big benefits:

And one big risk:

Most of system design is the art of keeping those benefits while removing that risk: more servers, load balancers, caches, replicas. That's the rest of this course.

Key idea: clients ask, servers answer, and the server is where truth and trust live. The rest of system design is about keeping that server fast and alive when millions of clients ask at once.

Check yourself

Your backend service calls a payment provider's API to charge a card. In that call, what is your backend?

Your new flashcards

Practice them now. With a free account they come back in your daily review.

Card 1 of 4