Every system you will ever build has two roles in it. One side asks. One side answers. The side that asks is the client. The side that answers is the server. Nothing about the machines matters as much as this split. Once you can see who is asking and who is answering, every diagram in this course gets easier to read.
Difficulty: Beginner · Know this first: F21 — TLDs: The End of Every Name
Every step charges a little time. The bar below is a worked example for this lesson's scenarios, not a measurement from a live system. The shape is honest: the server's work is the biggest slice, and a down server turns the whole bar into waiting. Step through the lesson or switch the scenario and watch the bar change.
Extra diagram · from scratch to master
Start with one client and one server. Add one pair at a time until you can see the roles everywhere.
Extra diagram · from scratch to master
Start with one server. Add clients one at a time until you can see how a server shares itself, and what happens when it cannot.
Pick an everyday action. The simulator names the client, the server, the request, and the response for it. The point is the pattern: every action on a computer is a client asking and a server answering, even when no network is involved.
Everyday actions, each one a client and a server. Printing has a client and a server too, and they sit on the same desk.
Try this: (1) Open a web page. Client: browser. Server: website. Request: give me this page. Response: the page. (2) Send a chat message. Client: your app. Server: the chat service. The response is not the message arriving. It is the service saying it got the message. (3) Print a document. Client: your laptop. Server: the printer. The response is the printer saying it took the job.
Three questions. No score is saved anywhere — this is just you against the material.
I take the same idea four times here. First I learn what it is and why it exists. Then I learn to use it and read what it tells me. Then I design with it so one failure cannot take the system down. Last I run it for the world.
Definition: A client asks. A server answers. The client starts the conversation and owns the experience. The server listens on a port, does the work, and answers in a fixed shape. A request is a question the server knows how to read. A response is an answer the client knows how to read.
Types:
Uses: I use this on every new system I meet. I name the client and the server in one sentence before I read any diagram.
Dimensions: At low traffic one client and one server is enough. What breaks first is a server that stops listening, and I notice it as a timeout on the client. It costs nothing to learn the split. It costs hours to debug a system without it. The trade is simple: the client waits, the server works, and the waiting is part of the cost.
Definition: Real systems are chains: a browser asks a web server, the web server asks an API, the API asks a database. Each link is a client and a server. A failure anywhere in the chain looks like a failure at the top, so I trace the chain link by link instead of blaming the first thing I see.
Types:
Uses: I use this on call. When a page fails, I ask which link in the chain broke, and I check each one in order from the client down.
Dimensions: As the chain grows, the slowest link sets the speed of the whole trip. What breaks is the link nobody owns, and I notice it when every client above it fails at once. It costs a diagram of the chain with an owner per link. The trade is that each link buys a separation of jobs, and each link adds a place where the trip can fail.
Definition: At this level one server serves many clients, and many servers share the work behind a load balancer. The balancer is a client to the servers and a server to the clients. Timeouts, retries, and limits decide what happens when the servers cannot keep up, and those decisions are part of the design, not an afterthought.
Types:
Uses: I use this when I design a service that must serve many users at once. I ask how many clients each server can carry, and what happens when that number is passed.
Dimensions: At ten times the clients the server's capacity is the wall. What breaks is the server that quietly takes more than it can carry, and I notice it in rising latency before anything fails outright. It costs capacity planning and limits that say no early. The trade is that saying no to some clients keeps the service up for the rest.
Definition: At this level the client-server split is an architecture choice, not a fact of nature. I decide what runs on the client and what runs on the server, where the boundary sits, and what crosses it. I design for clients I do not control: old apps, slow networks, users on bad connections. The server must be patient with all of them.
Types:
Uses: I use this when I review a system I did not build. I ask where the boundary sits and whether the server trusts the client too much.
Dimensions: At a hundred times the clients the server is a fleet, and the clients are a crowd I cannot see. What breaks is the assumption that clients behave well, and I notice it in abuse, not in errors. It costs rate limits, quotas, and the habit of never trusting a request just because it arrived. The trade is that a generous server is easy to use and easy to abuse, so generosity is budgeted, not unlimited.
Peer to peer is the exception that proves the rule. In a peer-to-peer system, every machine is both a client and a server at once, sharing pieces of a file with each other. The roles still exist. They just change hands many times a second. Most systems you will run are not peer to peer. They have a clear split, and the split is the design.
The client always knows more about the failure than the server does, because the client is the side that waits. A server that crashes never sees the requests that arrived after it died. The client's timeout is the only record of them. That is why client-side metrics matter as much as server-side ones.
A server should never trust the client. The client can be old, broken, or hostile. The server checks every request as if it might be wrong, because sometimes it is. Validation on the server is not distrust of the user. It is the server doing its job.
Long polling and websockets bend the rule without breaking it. The client still starts the conversation. The server just takes longer to answer, or keeps the conversation open so it can send more answers later. The roles do not change. The timing does.
At 10x the traffic, the shape holds and the numbers grow. More clients, more servers, same roles. I add servers behind the balancer and watch the slowest link in the chain.
At 100x, the design changes. The clients are spread across the world, so the servers move closer to them, and the boundary between client and server moves with them. The question stays the same: who asks, who answers, and what happens when the answer is slow or never comes.
A dashboard page stopped loading for one team and worked fine for everyone else. The server was healthy. The database was healthy. The team swore the page was down, and every other team swore it was up. Both sides were right.
Three things. First, the dashboard now shows a clear error when its API call fails, instead of spinning forever. A client that cannot reach its server should say so. Second, the on-call check for the dashboard now loads the page and calls the API, because a page that loads and a page that works are two different things. Third, I wrote down the rule: when one group fails and the rest work, the problem lives between that group and the server, not on the server. The client was right to complain. The server was right to be healthy. Both were true at once.
Design a file-sharing system for a team of 50 people. Files live on a server. People upload and download from laptops and phones. One person uploads a file while another downloads it.
Start with the count. 50 people, each uploading about 5 files a day, is 250 uploads a day, which is tiny. Each file is a few megabytes, so the storage grows by about a gigabyte a day if files average 4 MB. The server's work is not the count. It is the size. One server handles this easily, and the design question is not capacity. It is what happens when the server is down, and who can still work.
One server is simple and is a single point of failure. Two servers buy uptime and cost the problem of keeping the file lists in sync. Letting clients upload directly to storage buys speed and costs control over who uploaded what. And the naming question is a product decision, not a technical one: overwriting, renaming, or refusing a duplicate name are all defensible, but the choice must be made on purpose and shown to the user.