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.

PhonePhoneApp serverApp serverDatabaseDatabase
  • Phone — healthy
  • App server — healthy
  • Database — healthy
Round trips for this tap
not shown yet
  1. The phone asks. Tapping Profile makes the phone, the client, send a request to the server: GET /profile/42.
  2. The server reads data. The server keeps no profiles itself, so it reads user:42 from the database.
  3. The row comes back. The database sends the stored row back: the name, the photo link and the bio.
  4. The answer returns. The server turns the row into an answer for the phone: 200 OK, after 2 round trips in all.
  5. No memory between taps. Once it answers, the server forgets the phone, so the next request must say again who it is.
  6. Each tap starts over. The next tap starts a brand-new request, and the server treats it like the first one it ever saw.
  7. 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

  1. The client, such as a phone or browser, sends a request; the server does the work and answers.
  2. Most servers keep no data of their own, and read it from a database for each request.
  3. Each database call adds a wait inside the server, and the phone waits for all of them.
  4. A server that keeps no session between requests can be copied, so many servers can share the load.

Go deeper in the Request flow lab →

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 , 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 , 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

Pick a case to follow below

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 PunePhonethe client, in PuneApp server, in Mumbai, NOWApp serverin Mumbairequest arrivedNOWDatabase, next to the serverDatabasenext to the server
  • 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

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
Time so far
5ms
Network round trip
10ms
Pune to a server in Mumbai
Database read
2ms
inside the data centre

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

  1. 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.

  2. The request crosses the network

    The request is cut into small pieces called packets. pass each packet on, one step at a time, until it reaches the machine with the server's . Between continents, most packets travel through undersea cables.

  3. 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.

  4. The response comes back

    Pick a case to follow below

    With this case: With a login token, the server knew the request came from user 42, saved the change and answered 200 OK.

    Phone, the clientPhonethe clientApp server, keeps no memory, NOWApp serverkeeps no memoryremembers nothingNOWDatabase, next to the serverDatabasenext 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 4

    Step 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 remembers
    nothing
    from earlier requests
    Who is asking
    –
    not checked yet
    Bio saved
    no
    Answer
    –

    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 and the data. The code 200 means OK, and 404 means not found. The data is often for an app, or 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 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

Why does each request from an app carry who the user is, such as a session cookie or a login token?

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 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

A chat app asks the server for new messages every second. What is the main cost?

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?

A chat app wants to show a new message the moment it arrives. In the plain client-server model, what gets in the way?

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

A shop app sends an order for an item that costs $50, with price=5 in the request. What should the server do?

Apply it

One server can finish 500 requests a second. A sale sends 2,000 a second for a whole minute. What do users most likely see?

Judge a design

A team runs its whole app on one server. It handles today's traffic with room to spare. Which risk matters most?

Next: DNS, the lookup that turns a name such as shop.example.com into the server's IP address.

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.