Stage 1 · Foundations · Easy · 10 min
The client–server model
A client asks and a server answers. Follow one request from a phone to a server and back, and see what this model cannot do on its own.
What each interview level is expected to know
Learn first: nothing. This is a starting point.
After this lesson you can:
- Follow one request from a phone to a server and back, step by step.
- Explain why a server must never trust what the client sends.
- Name what plain request and response cannot do, such as pushing a new message.
Start here
See it in 60 seconds
One tap, start to finish
A client asks, a server does the work and answers, and every tap repeats that round trip, often with database calls inside it.
Scene 1 of 6 · The phone asks
Tapping Profile makes the phone, the client, send a request to the server: GET /profile/42.
- Phone — healthy
- App server — healthy
- Database — healthy
- Round trips for this tap
- not shown yet
- The phone asks. Tapping Profile makes the phone, the client, send a request to the server: GET /profile/42.
- The server reads data. The server keeps no profiles itself, so it reads user:42 from the database.
- The row comes back. The database sends the stored row back: the name, the photo link and the bio.
- The answer returns. The server turns the row into an answer for the phone: 200 OK, after 2 round trips in all.
- No memory between taps. Once it answers, the server forgets the phone, so the next request must say again who it is.
- Each tap starts over. The next tap starts a brand-new request, and the server treats it like the first one it ever saw.
- Now you try. Pick what the phone does, and count the round trips it causes. For example: Tapping "Open your feed" sends GET /feed, costing 3 round trips: 1 to the server, and 2 from it to the database. The server needs both reads before it can answer, so the phone waits for both.
Scene 1 of 6: The phone asks. Tapping Profile makes the phone, the client, send a request to the server: GET /profile/42.
Key points
- The client, such as a phone or browser, sends a request; the server does the work and answers.
- Most servers keep no data of their own, and read it from a database for each request.
- Each database call adds a wait inside the server, and the phone waits for all of them.
- A server that keeps no session between requests can be copied, so many servers can share the load.
In plain words
You tap a friend's profile in an app. The app sends a request, GET /profile/42, to a computer in a data centre. That computer reads the profile from its database and sends it back. The app is the client: the side that asks. The computer in the data centre is the server: the side that waits for requests and answers them.
One server answers many clients at once, often thousands. Each request crosses the network as small (A small piece of data sent across a network. A big message is cut into many packets.), and the answer comes back the same way. The client needs to know only what to ask for and what the answer looks like, not how the server works inside. In this simple setup, every device asks one server, and that server uses one shared database. So there is one main copy of the data. Larger systems add caches and extra copies, and must then decide how those copies stay up to date.
The problem it solves
Many users need the same data: a shop's prices, its stock, your orders. If each phone kept its own copy, the copies would soon disagree. So the data and the rules live in one place, the server. Every device asks that one place.
Why it matters
Almost every system you will design is this model with parts added: a (A server that receives every request first and passes each one to one of several servers behind it.), a (A small, fast store that keeps copies of popular data, so most reads skip the slower database.), a database. Each part sits somewhere on the path of one request, so learn that path first.
A worked example
A server that takes 50 ms to answer one request can, in theory, finish about 20 requests per second, since 1,000 ÷ 50 = 20. If 5,000 clients each send one request a second, the server needs about 5,000 ÷ 20 = 250 requests in progress at the same moment. That does not mean 250 servers. One server can work on many requests at once, because it moves to another request while each one waits for the database.
Think of it like…
Think of a vending machine. You pick an item and pay, and the machine checks the money and drops the item. You never see how it works inside.
Where this analogy stops working
Ask, then get an answer, is the useful part. But a vending machine serves one person at a time and holds its own stock. A server works on many requests at once. It usually keeps the data in a database behind it, not inside itself.
Try it
See it working
With this case: With the server in Mumbai, the phone waited about 12 ms: 10 ms on the network and 2 ms at the database.
- Phone — the client, in Pune — healthy
- App server — in Mumbai — healthy — NOW — request arrived
- Database — next to the server — healthy
- Request
- Answer
Step 1 of 3 · App server
Done: The phone sends GET /profile/42
- What happens
- The request leaves Pune as packets and reaches the server in Mumbai after about 5 ms.
- Why
- Routers pass each packet on, one step at a time, until it reaches the machine with the server's IP address.
- What changes
- The packets stayed in one part of India.
- Next
- The server reads user:42
Step 1 of 3: App server. The phone sends GET /profile/42. The request leaves Pune as packets and reaches the server in Mumbai after about 5 ms.
What these pictures simplify. This picture uses round example times: 10 ms there and back to Mumbai, 200 ms to Virginia, 2 ms to the database. Real times depend on the network path and the load. The Request flow lab adds DNS, a CDN and a cache to the same trip.
Also try: Request flow
Mechanics
How it works
The client starts
A client is the program that asks: a browser or a phone app. The user types a web address or taps a button, and the client builds a request. In this model the server does not speak first: it waits to be asked.
The request crosses the network
The request is cut into small pieces called packets. (A network device that passes each packet on, one step at a time, towards the machine it is addressed to.) pass each packet on, one step at a time, until it reaches the machine with the server's (The number that identifies a machine on a network, such as 203.0.113.7. Packets are sent to it.). Between continents, most packets travel through undersea cables.
The server does the work
A server is a program that waits for requests. It checks the request, runs the app's rules, and reads or writes the database.
The response comes back
Pick a case to follow belowWith this case: With a login token, the server knew the request came from user 42, saved the change and answered 200 OK.
Phone, the client Phone the client App server, keeps no memory, NOW App server keeps no memory remembers nothing NOW Database, next to the server Database next to the server - Phone — the client — healthy
- App server — keeps no memory — healthy — NOW — remembers nothing
- Database — next to the server — healthy
- Request
- Answer
Step 1 of 4Step 1 of 4 · App server
Done: The first request is over
- What happens
- The server answered GET /profile/42 with 200 OK. Then it kept nothing about the phone.
- Why
- Nothing links one request to the next, so the server can answer any phone the same way.
- What changes
- The next request starts from zero.
- Next
- The phone sends the change and its login token
The server remembersnothingfrom earlier requestsWho is asking–not checked yetBio savednoAnswer–Step 1 of 4: App server. The first request is over. The server answered GET /profile/42 with 200 OK. Then it kept nothing about the phone.
What these pictures simplify. This picture uses one phone, one server and no other parts. Real apps put more between them, such as DNS, a load balancer and a cache; later lessons add each one.
The server sends back a (A three-digit number in every HTTP answer that says how the request went: 200 means OK, 404 means not found, 500 means a server error.) and the data. The code 200 means OK, and 404 means not found. The data is often (A plain-text format for data, such as {"id": 42, "name": "Asha"}. Most web APIs send and receive it.) for an app, or (The text format web pages are written in. The browser reads it and draws the page.) for a web page. Nothing links this request to the next one. So the next tap must say again who the user is, with a (A record the server keeps for a logged-in user. The browser holds only its id, and sends it with every request.) (A small value that a site asks the browser to keep, and to send back with every request to that site.) or a login token.
In the picture, the phone sends a second request to change the bio. With a login token, the server knows it is user 42, saves the change and answers 200 OK. With nothing, it answers 401 Unauthorized, because it has already forgotten the first request.
Use it when
- Web and mobile apps: many devices share one set of data, kept behind the server in one main database.
- Anything that needs a trusted check, such as a payment: the user controls the client and can change it, so the server must decide.
Skip it when
- Sharing large files among many users, as BitTorrent does: each computer both asks and answers, so no central server carries all the traffic. This is called peer-to-peer (P2P).
- Work that needs no shared data, such as a calculator: it can run on the device with no server at all.
Check yourself
Judgement
Trade-offs and how it fails
What you give up
- Performance
- Every request goes to the same server, so that one server decides how many users the app can serve. When it is slow or full, every client waits. Later lessons spread that load across many servers.
- Complexity
- The model is easy to reason about: the server holds the data and the rules, and each client asks. The price is that most features stop working when the device has no network.
Failure modes
- Overload: a sudden rush sends more requests than the server can handle. Requests (A waiting line for work. One part adds messages, and another takes them off and handles them later, at its own pace.) up, then time out, and users see errors such as 503 Service Unavailable.
- A single point of failure: with one server, every client stops when it stops.
- Trusting the client: a price or a user id sent by the app can be faked, so the server must check every request.
In the real world
- CERN, the European physics lab, records that Tim Berners-Lee had the first web server and browser running there by the end of 1990. Both ran on a NeXT computer.
- You can watch the model in any browser. Open the developer tools and pick the Network tab. It lists each request the page sends and the status code that comes back.
Trade-offs to be ready to discuss: Client side vs server side
Check yourself
Interview
What interviewers look for
- Start the design with three boxes: client, server and database. Say what each request carries and what comes back.
- Say that distance costs time. Light in fibre covers about 200 km each millisecond, so a far-away server is slow however fast its code is.
Say it out loud: A request goes from New York to London and back. Why can it never be much faster than about 60 ms?
Expected depth by interview level
Levels describe the depth interviewers probe, not years of experience. Choose a level on the learning path to highlight it.
- JuniorCore
- Explain a request from browser to server and back.
- MidExpected
- Stateless servers, which keep no memory between requests, and where that data lives instead.
- SeniorUseful
- Assumed knowledge; rarely discussed on its own.
- StaffUseful
- Assumed knowledge; rarely discussed on its own.
Practice
Apply it
Three harder questions
The first two use the idea on a new case. The last asks you to judge a design.
Apply it
Apply it
Judge a design
Go deeper
Sources and further reading
First-hand sources to check this page against and to go further. They are standards, official docs, original papers, and guides from engineering and security teams. Each link was opened on 8 November 2026.
- Official docsHow does the Internet work?MDN Web DocsPackets, routers, IP addresses and how two computers far apart reach each other.
- Official docsAn overview of HTTPMDN Web DocsThe request and response a browser and a server exchange, with real examples.
- Engineering guideThe Twelve-Factor App: ProcessesAdam Wiggins (Heroku)Why servers should keep no user state in memory, so any server can answer any request.