system-design · beginner

Client–Server Architecture — Request Work From a Shared Machine

Start here

Client–server architecture is a way of organizing software into two roles:

  1. A client — the program the user touches (browser, mobile app, desktop app, or even another service).
  2. A server — a program that waits for requests, does work, and sends responses.
The client says “please do X.” The server decides whether X is allowed, does the work (or asks a database), and answers.

You should care because almost every internet product you use is client–server: banking apps, email, Learning Lab itself. Later ideas—APIs, load balancers, microservices—are refinements of this basic split.

What you will learn

  1. Define client and server without jargon.
  2. See why the split exists (shared data, security, updates).
  3. Walk a request from button click to database and back.
  4. Contrast with peer-to-peer and pure local apps.
  5. Work a complete notes-app example.
  6. Know failure modes: server down, slow network, chatty clients.
  7. Connect this pattern to APIs and multi-server farms.

What you should know first

TopicWhy
System Design FoundationsOverall map of backend pieces
Everyday web useYou already use clients and servers daily

Words you need before we begin

TermPlain English
ClientProgram that initiates requests on behalf of a user or another system.
ServerProgram that listens for requests and provides services.
Request / responseThe message pair: “please…” and “here is the result / error.”
APIApplication Programming Interface — the agreed rules for those messages.
Stateless server (common goal)Server does not need to remember prior requests in its own memory to handle the next one; state lives in databases/tokens.
BackendServer-side systems users do not run on their phones.
FrontendClient-side UI code.
Round tripOne request to the server and its response back.

Simple story: restaurant table service

You (the client) sit at a table and order. Kitchen staff (the server) cook and return food. You do not walk into the walk-in freezer yourself. Many tables share one kitchen so recipes, inventory, and hygiene rules stay consistent.

Where the analogy stops: digital servers handle thousands of “tables” at once, can clone themselves behind a load balancer, and must survive network packets vanishing mid-order.

The problem without client–server

Everything local only

A pure offline spreadsheet on one laptop works offline—but teammates cannot share one live source of truth, and you cannot push a security fix to every copy instantly.

Everyone is a peer for everything

Peer-to-peer has uses (file sharing, some games, blockchains), but banking “every phone holds the ledger” is a nightmare for consistency, audit, and fraud control.

Client–server centralizes authoritative rules and data while clients stay replaceable.

Step-by-step explanation

Step 1 — Client gathers intent

User taps “Save note.” The client validates basic input (empty title?) and prepares a request.

Step 2 — Client sends a request over the network

Usually HTTP or HTTPS (Hypertext Transfer Protocol / Secure). Example idea: POST /notes with JSON body.

Step 3 — Server authenticates and authorizes

Step 4 — Server executes business logic

Apply rules: length limits, spam checks, quota.

Step 5 — Server reads/writes durable storage

Database insert for the note row.

Step 6 — Server responds

Success with new noteId, or an error code the client can show.

Step 7 — Client updates the UI

Show the saved note or a clear error—not a silent failure.

Visual mental model

sequenceDiagram
  participant U as User
  participant C as Client app
  participant S as Server
  participant D as Database

U->>C: Tap Save
C->>S: HTTPS request
S->>S: Auth + rules
S->>D: Write note
D-->>S: OK
S-->>C: 201 + noteId
C-->>U: Show saved note

Learning question: If the database is down, which side should explain the failure to the user?

Caption: The server owns the truth; the client owns the experience of that truth.

Complete worked example: team notes app

Starting situation

Build a notes app for a 20-person team. Notes must sync across phones and laptops. Only the author can delete their notes.

Constraints

Decisions

PieceChoiceWhy
ClientsNative/web appsMultiple devices
ServerOne HTTPS APISingle place for rules
DataPostgresShared durable store
AuthSession or token after loginServer enforces delete rights

Execution path

  1. Login client → server verifies password hash → returns token.
  2. Create note client → server checks token → inserts row with userId.
  3. Delete note client → server checks note.userId == token.userId → delete or 403.

Failure behavior

FailureBehavior
Server process diesClients see errors/timeouts until restart or second instance
Network drop after saveClient may retry; server should be idempotent for creates if possible
Malicious clientServer still enforces auth—never trust the client alone

Outcome

All devices share one notebook. Limitation: offline editing needs extra design (local queue + sync), still ultimately reconciling with the server.

How it works in production

Modern “one server” is often:

Still client–server: clients do not become the system of record.

Ownership

Failure modes

ModeTriggerUser impactMitigation
Server outageDeploy/crashApp useless for online featuresMulti-instance, health checks
Chatty clientToo many tiny requestsSlow UI, hot APIBatch, cache, pagination
Trusting the clientValidation only in UISecurity bugsServer-side checks always
Fat client assuming LAN latencyMobile on weak networkSpinners foreverTimeouts, offline UX
Version skewOld app vs new APIBreakageAPI versioning, graceful fields

Trade-offs

ChoiceBenefitCost
Client–serverShared truth, central securityNeeds network; server is critical
Fully localWorks offlineHard multi-user sync
Peer-to-peerLess central infraConsistency and abuse harder
Server-heavy logicEasier rule updatesMore round trips
Client-heavy logicSnappy UIDrift and security risk

Compare with related concepts

ConceptRelationship
APIThe language clients use to talk to servers
MicroservicesMany servers, still clients call them
Load balancingMultiple server copies for one logical service
Peer-to-peerNodes act as both client and server roles

Common misunderstandings

  1. “The browser is the server.”
The browser is a client. The server is elsewhere (or localhost in dev).
  1. “If the UI hides a button, the action is impossible.”
Attackers call APIs directly. Server must enforce rules.
  1. “Client–server is outdated because of microservices.”
Microservices are still servers; clients still call them.
  1. “Servers must store session in memory.”
Prefer shared stores/tokens so any instance can serve the next request.

Check your understanding

  1. Define client and server in one sentence each.
  2. Why put delete permission checks on the server?
  3. What is a round trip?
  4. Name one failure that is not the server’s crash.
  5. How does client–server differ from peer-to-peer?

Practice

  1. List three clients you used today and what server they likely called.
  2. Draw the save-note sequence including an auth failure.
  3. Explain why “validation only in JavaScript” is unsafe.
  4. Design offline: what does the client store until the server is back?
  5. Map client–server onto a food-delivery app (customer app, restaurant app, backend).

Revision summary

Glossary

TermDefinition
Client–server architectureSplit into requestors (clients) and providers (servers).
BackendServer-side systems.
FrontendClient-side interface.
Stateless serviceHandles each request without relying on sticky local memory.

Abbreviations and terminology

What to learn next

  1. What Is an API?
  2. HTTP and HTTPS
  3. Load balancing
  4. System Design Foundations

Deeper production notes

Horizontal scaling of the server tier

When one server process cannot handle all clients, you run many identical server instances behind a load balancer. Clients still believe they talk to one logical service. Session data should live in cookies/tokens or a shared store so any instance can handle the next request. Sticky sessions are a last resort and reintroduce single-instance pain when that instance dies.

Where business rules must live

UI validation improves usability. Authorization, pricing, and integrity rules must live on the server (or a trusted service the server calls). Otherwise a modified client or raw HTTP tool bypasses your product logic. Treat every request as potentially hostile or buggy.

Evolution path teams actually take

  1. Single server + single database (fine for early products).
  2. Multiple servers + shared database + reverse proxy.
  3. Read replicas, caches, and async workers for hot paths.
  4. Split services only when team or scaling boundaries demand it.
Skipping straight to step 4 without traffic or org pain usually adds outages without benefits. Client–server remains the mental model at every step.

Observability on the boundary

Log request ids on the client when possible and always on the server. Trace one user action across hops. Metrics that matter at the API edge: request rate, error rate, latency percentiles—not only CPU on one box.

FAQ from first-time learners

Q: Is the database the server?
A: The database is usually a dependency of the server. The API server is the client of the database.

Q: Can a server be a client?
A: Yes. Service A often calls Service B—A is B’s client.

Q: Do mobile apps change the model?
A: No. Mobile apps are clients; they still call servers for shared data.

Track: Software Design and Architecture

Previous: Batch vs Stream Processing — When to Wait, When to Flow

Next: Fan-out on Write vs Fan-out on Read

By Shubham Jain

All articles · Study paths

Shubham Jain · Learning Lab