Client-Server and Peer-to-Peer

What is the client-server model in a computer network?

The client-server model is a way for one device to request something and another to respond. Learn its parts, everyday examples, and how it fits networks.

On this page
  1. The parts of the model
  2. Everyday examples
  3. How one request works
  4. One machine can be both
  5. Benefits and trade-offs
  6. How it relates to server-based networks

In the client-server model, a client sends a request, and a server sends back a response. The client is the program or device that asks for something, such as a web page, a file, or a login check. The server is the program or device that waits for those requests and provides the answer.

The parts of the model

  • Client: a program, such as a web browser or an email app, or the device it runs on.
  • Server: a program that listens for requests on the network and responds, such as a web server or a mail server, or the machine it runs on.
  • Network: the connection between them, which carries requests and responses using IP addresses and port numbers.

Everyday examples

  • A web browser asks a web server for a page.
  • An email app asks a mail server for new messages.
  • A computer asks a DNS server to translate a name like example.com into an IP address.
  • A workstation opens a shared folder on a file server.
  • An application asks a database server for records.

How one request works

  1. The client connects to the server’s address. Services usually listen on a known port number. Secure web traffic, for example, usually uses port 443.
  2. The client sends a request in a format both sides understand.
  3. The server processes the request. This may mean reading a file or checking a password.
  4. The server sends a response back to the client.
  5. The client shows the result or uses it.

These messages sit at the application layer of the network, and services provided by application layer explains what that layer does.

One machine can be both

The model describes roles, not hardware. One computer can run a server program that other machines use, and also run a client program for its own user. A server can be a physical machine in a closet, a virtual machine, or a service run by someone else. Clients and servers do not have to be on the same local network, and many clients reach servers across the internet.

Benefits and trade-offs

The model keeps data and rules in one place, so updates and backups can happen on the server. It also lets many clients use the same service.

The trade-off is dependence. The server has to be running and reachable, and it has to handle the load from every client. Central systems also need backups and security, because a problem on the server can affect everyone who depends on it.

How it relates to server-based networks

A server-based network is organized around this model. Dedicated servers provide shared resources, and clients use them. A peer-to-peer network does not use fixed roles like this, although a peer can act as a client and a server at the same time. For a comparison of the two designs, see the server based network and peer-to-peer network overview.

The complete guide to client-server and peer-to-peer

Server-Based Network vs Peer-to-Peer Network
Read the guide

Keep exploring

Guides from other topics

All topics →