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
- Find the server. The client turns a name into an address (DNS) and opens a connection, usually TCP with TLS on top.
- Send the request. For web traffic that is an HTTP request: a method (
GET,POST), a path, headers and possibly a body. - 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.
- 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.