Skip to content

Client-Server Model

Almost every web system uses the client-server model: a client sends a request, the server processes it and sends back a response.


sequenceDiagram
participant Client as 📱 Client
participant Server as 🖥️ Server
Client->>Server: HTTP GET /api/users
Server->>Server: Process request
Server->>Client: HTTP 200 { "users": [...] }
Client->>Server: HTTP POST /api/orders
Server->>Server: Create order
Server->>Client: HTTP 201 { "id": 123 }

Analogy — Restaurant:

  • Client = you (the customer) — you tell the waiter what you want
  • Server = the kitchen — they cook your food
  • Network = the waiter who carries messages back and forth

ComponentRoleExamples
ClientInitiates requestsBrowser, mobile app, IoT device
ServerProcesses requests, sends responsesWeb server, database server, API server
NetworkTransports messagesInternet, local network

AspectStatelessStateful
Stores session?No — each request is independentYes — remembers past requests
Scales easily?✅ Yes (any server handles any request)❌ Harder (requests must go to the same server)
ExampleREST APIFTP, old-school Java sessions

  • Stateless is easier to scale but may require more data in each request (e.g., JWT tokens).
  • Stateful is simpler to code but harder to scale.
  • Modern systems prefer stateless servers + external session store (Redis).

  • Clients ask, servers answer. It’s like ordering food at a restaurant.
  • Stateless = the server forgets you after each request. Stateful = the server remembers.
  • Stateless scales better — any server can handle any request.