Course contents

01. System Design Fundamentals Lesson 3 of 8

Client-Server Architecture

See how clients and servers exchange requests and responses, where response time goes, why a shared server shares its bad days, and what a single server costs.

10 minBeginner6 steps
Loading the interactive simulation…
Loading the knowledge check…

Summary

  • The client initiates with a request; the server does the work and returns a response.
  • Response time is network time out, server time, and network time back; distance is paid twice.
  • A server is shared, so its load is the sum of all clients and its overload hurts all of them.
  • One server is a single point of failure; redundancy comes later in the curriculum.
  • Centralising data and logic gives one source of truth, one enforcement point and simple updates.
Deep diveHow it works, trade-offs, failure modes, misconceptions and the interview angle.

What it is

Client-server is the arrangement behind almost every application you use. A server is a program that owns some data or capability and waits for requests. A client is a program that needs that data or capability and asks for it. The client sends a request, the server does the work and sends back a response. Browsers, mobile apps and other services are clients; web servers, API servers and databases are servers. The same program can be both: an API server is a server to the browser and a client of its database.

Why it exists

Putting data and logic in one place solves problems that are hard to solve any other way. There is one authoritative copy of the data, so every client sees the same account balance. Security rules are enforced where clients cannot tamper with them. A bug fix deployed to the server reaches every user immediately. Clients can stay small and varied: a browser, a phone and a smart TV can all use the same server.

How it works

  1. Find the server. The client turns a name into an address (DNS) and opens a connection, usually TCP with TLS on top.
  2. Send the request. For web traffic that is an HTTP request: a method (GET, POST), a path, headers and possibly a body.
  3. Server work. The server parses the request, checks who is asking, runs the logic, often calls its own dependencies (databases, caches, other services) and builds a response.
  4. Send the response. A status code, headers and a body travel back over the same connection.

Response time is the sum of the parts: network time to the server, waiting time if the server is busy, processing time, and network time back. Network time depends on distance and the network type; a client on another continent or a mobile network pays it on every round trip, which is why the lesson's phone waits almost three times as long as the nearby browser for the same work.

Most servers are designed to be stateless between requests: each request carries what the server needs (a session token, the IDs involved), and any lasting state lives in a database. That lets any copy of the server answer any request, which is the basis for scaling and failover later.

When to use it

Nearly always, when several users or devices need the same data, when access must be controlled, or when logic must be updated centrally. Web applications, mobile back ends, SaaS products, internal business systems and APIs between services are all client-server.

When not to

  • Peer-to-peer fits when there is no natural owner of the data or when central capacity would be the problem: file distribution to millions of peers, some real-time media between two users, or systems designed to have no central authority.
  • Local-first applications keep the primary copy on the device and sync in the background; they work offline and feel instant, at the cost of conflict resolution.
  • Purely local tools need no server at all.

Trade-offs

Choice You gain You pay
Central server One source of truth, central security and deploys Shared capacity, a single point of failure until made redundant
Thin clients (logic on the server) Consistent behaviour, easy updates Every action needs a round trip; slow on far or poor networks
Thick clients (logic on the device) Responsive, can work offline Harder to update, duplicated logic, client can be tampered with
Stateless servers Any server can take any request; easy to scale State must go to a database or cache, adding a hop

Alternatives

  • Peer-to-peer: every node is both client and server. No central bottleneck, but discovery, consistency and trust are hard.
  • Local-first / sync: clients own their data and sync through a relay. Great offline behaviour; conflict resolution required.
  • Push and streaming (WebSockets, server-sent events): still client-server, but after the client opens a connection the server can send updates without being asked.

Failure modes

  • Server down: every client fails. Redundant servers behind a load balancer remove this single point of failure.
  • Server overloaded: requests queue and are rejected for every client, including ones that did not cause the load ("noisy neighbour"). Rate limits and quotas per client contain it.
  • Network problems: a client that cannot reach the server cannot work at all unless it caches data locally.
  • Slow server, no timeout: a client that waits forever for a reply ties up its own resources. Clients need timeouts.

In production

A real request rarely goes straight from client to application server. It typically passes DNS, a CDN or edge proxy, a load balancer or reverse proxy, then one of many identical application servers, which in turn are clients of databases and other services. Clients set timeouts and retry carefully; servers limit concurrency and reject excess load early rather than collapsing. Latency to distant users is reduced by serving them from nearby regions or edge caches.

Common misconceptions

  • "Client and server are kinds of machines." They are roles. One process can be a server to one party and a client to another.
  • "A faster server fixes slow responses for far-away users." Network time is paid regardless; only moving the server (or a cache) closer reduces it.
  • "Each client gets its own part of the server." Without explicit limits, clients share workers and queues, so one heavy client slows everyone.
  • "WebSockets are not client-server." The client still opens the connection to a server; only the direction of later messages changes.

Interview angle

Client-server is assumed rather than asked, but it shows up in how you reason about latency ("how many round trips does this page need?"), state ("where does the session live?") and failure ("what happens when this server dies?"). Saying that servers should be stateless so they can be replicated, and that clients need timeouts, are small points that signal experience.

Model assumptions

The simulation is a simplified model, not a benchmark. The server has 4 workers, a 50 ms mean service time (lognormal, cv 0.3) and room for 20 waiting requests; beyond that it rejects. Your browser and the phone each send 4 requests per second at a steady pace; the other users arrive randomly (Poisson). Network hops take a fixed 30 ms or 120 ms each way with no packet loss; connection setup, DNS and TLS are not modelled. Utilisation is the share of busy workers, not CPU. Numbers show behaviour and orders of magnitude only.

The lesson as textEvery step of the simulation, written out.
  1. 1. The client asks, the server answers

    Your browser is a client: it starts every conversation by sending a request. The server waits for requests, does the work (here about 50 ms) and sends back a response. The server never contacts the client on its own.

    Watch one packet go out and come back. That round trip is the basic unit of almost every system in this Lab.

    Scene: Your browser sends four requests per second to the server, 30 ms away. Each response comes back after about 110 ms.

    Key idea: In client-server, the client initiates and the server responds; one request, one response.

  2. 2. Where the time goes

    Your request takes about 110 ms: 30 ms to reach the server, about 50 ms of work, 30 ms back. A phone on a mobile network 120 ms away asks for exactly the same thing and waits about 290 ms.

    The server did the same work for both. The difference is distance, and it is paid twice, once each way. No amount of server power removes it.

    Scene: A phone 120 ms away joins. Its requests take about 290 ms, yours about 110 ms; the server spends the same 50 ms on each.

    Key idea: Response time = network time out + server time + network time back.

  3. 3. One server, many clients

    Thousands of other people use the same service: here, a crowd sending 30 requests per second. Every client talks to the same server, so the server sees the sum of all their traffic and is now about half busy.

    That sharing is the point of the model: data and logic live in one place, every client sees the same state, and an update to the server reaches everyone at once.

    Scene: Your browser, the phone and a crowd of other users all send requests to the same server, which is about half busy. Everyone gets answers.

    Key idea: A server is shared: its load is the sum of every client’s requests.

  4. 4. Other people’s traffic slows you down

    A second in, the crowd grows to 100 requests per second, more than the server can finish. Requests queue behind each other and the overflow is rejected.

    You did not change anything, yet your requests now wait in the same queue and some of them fail. Clients share the server’s capacity, so they also share its bad days.

    Scene: The crowd sends 100 requests per second. The server is fully busy with a full queue; your requests wait much longer and some are rejected.

    Key idea: Clients are not isolated: when the shared server is overloaded, every client feels it.

  5. 5. The server goes down

    Traffic is back to normal. Then, a second and a half in, the server crashes. Requests it was working on are lost, and every new request, from whoever and wherever, is refused.

    In the basic model the server is a single point of failure. Clients have nowhere else to go. Later lessons add copies of the server, a load balancer and health checks to fix exactly this.

    Scene: The server crashes. Requests in progress are lost, and every new request from your browser, the phone and the other users fails with a refused connection.

    Key idea: With one server, its failure is a total outage for every client.

  6. 6. Why most systems are client-server

    The server is back. Client-server wins because it centralises what matters: one copy of the data, one place to enforce security, one thing to update. Clients stay thin and can be browsers, phones or other services.

    The costs are the ones you just saw: the server’s capacity is shared, distance adds latency, and one server is one failure away from an outage. Peer-to-peer systems avoid a central server but make consistency, security and discovery much harder.

    Scene: The server has recovered. Your browser, the phone and the other users are all served again; the server is about half busy.

    Key idea: Client-server trades a central bottleneck and failure point for simplicity, control and one source of truth.