Client-Server Architecture

The fundamental communication model of the Web: clients ask, servers answer

The Request-Response Model

The client-server model is a fundamental model of the Web. The client initiates a request; the server processes it and sends a response. The server never initiates communication — it only responds.

    ┌────────────┐                         ┌────────────┐
    │            │  ──── Request ─────────>│            │
    │   Client   │                         │   Server   │
    │  (asks)    │  <──── Response ────────│  (answers) │
    │            │                         │            │
    └────────────┘                         └────────────┘

    Types of clients:                      Types of servers:
    - Web browser                          - Web server (Apache, Nginx)
    - Mobile app                           - Application server (Node, PHP)
    - CLI tool (curl, wget)                - Database server (PostgreSQL)
    - Another server (API call)            - File server
    - IoT device                           - Mail server

This model has a critical implication: the server is passive. It sits and waits. It generally cannot push data to clients unless a client first establishes a connection. (Technologies like WebSockets upgrade this model, but the initial connection is always client-initiated.)

Why This Matters

  • Polling vs Pushing: If the server has new data, it can't tell the client. The client must ask (poll). WebSockets and Server-Sent Events (SSE) are workarounds for this limitation.
  • Statelessness: Each request is independent. The server doesn't inherently remember previous requests. State must be managed explicitly (cookies, sessions, databases).
  • Scalability: Because the server is stateless, you can put multiple servers behind a load balancer, and any server can handle any request.