Practice this topic in a realistic system design interview
When many people use the same application, they need a shared place for important data and rules. Your phone should not be the only place that knows your bank balance, shopping cart, or account permissions. That information needs to live somewhere central and trusted.
Client-server architecture is the name for that split. A client asks for something. A server handles the request, checks the rules, works with shared data, and sends back a response.
The idea is simple. The real skill is learning what gets added around it in production: DNS, HTTPS, load balancers, caches, databases, queues, and monitoring. Those pieces exist because real systems have many users, unreliable networks, security risks, and changing traffic.
This chapter explains client-server architecture in plain terms: what clients and servers do, how a request travels, how 1-tier, 2-tier, 3-tier, and N-tier systems differ, how this model scales, and where it can fail.
Loading simulation...
Client-server architecture is a way to structure a system so that one side asks for work and the other side does the work.
The client is usually close to the user. It might be a browser, a mobile app, a desktop app, or another backend service. The server usually owns the parts that must be protected or shared: business rules, account data, databases, files, AI models, payment access, and internal services.
One useful way to think about it is this:
The client asks, "Can you do this for me?"The server answers, "Yes, no, or here is the result."
When you open a web page, your browser is the client. It finds the website, opens a secure connection, sends a request, receives HTML, CSS, JavaScript, images, and data, then draws the page on your screen.
Behind the scenes, the server side may include a CDN, cache, load balancer, application server, internal services, and database.
Client-server architecture became popular because software moved from single-user programs to shared systems.
Early systems used terminals connected to a central mainframe. Later, desktop apps connected directly to shared databases. Web apps moved much of the logic back to backend servers. Modern systems often combine browser and mobile clients, CDNs, API gateways, backend services, managed databases, event streams, and third-party APIs.
The tools changed, but the core pattern did not: clients ask for work; servers coordinate that work and protect shared resources.
Most client-server communication follows a request-response flow. The exact details vary, but the story usually looks like this:
algomaster.io into a network address.GET /api/playlists/42.algomaster.io.443.Consider an AI chat application:
This is still client-server architecture. The "server" is just not a single process anymore. It is a group of services working together.
Client-server systems are often described by how many tiers they have.
A tier is a layer with a clear job. Some tiers are separate deployable services. Others are just logical layers inside the same system. The point is to separate responsibilities so the system is easier to understand and change.
In 1-tier architecture, the user interface, business logic, and data storage all live together. There is no remote server involved.
Common examples include a local spreadsheet, a single-user desktop accounting tool, or a developer utility that stores data in a local file.
Best suited for local, offline, single-user applications.
In 2-tier architecture, the client talks directly to a server. A common example is an internal desktop app that connects straight to a central PostgreSQL or SQL Server database.
Suitable for controlled internal environments. It is usually a poor fit for public internet-facing systems.
3-tier architecture separates the user interface, backend logic, and data storage.
In an e-commerce system, the mobile app calls an order API. The application server checks the cart, verifies inventory, authorizes payment, writes the order to the database, sends an event, and returns an order confirmation.
This is the common baseline for web applications, SaaS products, mobile backends, and many internal platforms.
N-tier architecture extends the 3-tier model with more layers or services. Teams usually add these layers when the system needs more scale, security, specialization, or independent ownership.
Common additions include API gateways, authentication services, caches, search services, queues, analytics pipelines, model services, and backend-for-frontend layers.
In real systems, N-tier does not always mean every layer talks only to the next layer. It means each important responsibility has a clear boundary and a clear interface.
A production AI assistant may use a web client, a backend-for-frontend, an authentication service, a conversation service, a retrieval service, a vector database, a model gateway, GPU workers, object storage, and an event stream for analytics.
Best for systems where scale, team boundaries, strict compliance rules, or specialized workloads justify the extra complexity.
Client-server architecture is everywhere because it solves a very practical problem: it gives the system one trusted place to handle shared work.
Important rules can live on the server instead of being copied into every client.
For example, an online banking app should not decide on the phone whether a transfer is allowed. The server should check the account, permissions, limits, fraud signals, and audit requirements.
This matters because clients are hard to trust. Users can run old versions, lose network access, modify local data, or even tamper with requests. The server is where the system can enforce the final decision.
Clients should not connect directly to private databases, payment systems, internal APIs, or model providers. If a mobile app contains a database password or private API key, that secret can eventually leak.
In a client-server design, the client talks to your backend. Your backend talks to protected systems. That extra step is one of the main reasons the model is so useful.
Server-side behavior can change without forcing every user to update their app immediately.
For example, you can improve ranking logic, add fraud checks, change a database schema, or adjust pricing rules on the server. As long as the API contract stays compatible, old clients can keep working.
Servers give teams a central place to collect logs, metrics, traces, errors, and audit records. That makes it much easier to answer questions like:
Good visibility turns production from a guessing game into an engineering problem you can investigate.
The same centralization that makes client-server systems useful can also create problems. If too much depends on one server, one database, one region, or one external service, that part can become a bottleneck or a single point of failure.
Every network call takes time. A request from a phone to a server might cross mobile networks, Wi-Fi, routers, firewalls, proxies, and load balancers before it reaches application code.
Latency gets worse when the server also calls databases, caches, third-party APIs, or other internal services. A request path is only as fast as the slowest important step.
Networks fail. Databases slow down. Load balancers take instances out of rotation. Third-party APIs time out. Clients disconnect halfway through a request.
Good client-server systems expect this. They use timeouts, retries with backoff, health checks, failover, and queues where appropriate. They also use idempotency keys, which are request IDs that help the server handle a retry safely without doing the same work twice.
The goal is not to prevent every failure. That is impossible. The goal is to keep one failure from taking down the whole user experience.
State is anything the system needs to remember: login sessions, carts, preferences, documents, orders, messages, and so on.
State can make scaling harder. If one application server keeps a user's session only in memory, later requests may need to return to that exact server. That makes load balancing and failover harder. Many systems move session state to a shared store so any healthy server can handle the next request.
The server is a major security boundary. It should authenticate callers, authorize actions, validate input, rate-limit abuse, protect secrets, and log important events.
Never assume the client is honest. A client can hide a button in the UI, but only the server can reliably prevent the action.
Clients do not all update at the same time. A mobile app released months ago may still call your API today.
That means APIs need careful evolution. Removing fields, renaming endpoints, or changing response shapes can break older clients. Production APIs often need backward-compatible changes, versioned endpoints, or gradual migrations.
Client-server systems also have cost trade-offs. More servers, more database calls, more AI model calls, more logs, and more cross-region traffic all cost money.
Good architecture considers cost as part of the design, not only after the bill arrives.
Modern systems rarely rely on one server process. They scale by adding capacity in the places that are under pressure.
If application servers are stateless, you can run more copies of them behind a load balancer. Stateless means the server does not keep important user-specific data only in local memory. Any healthy server can handle the next request.
This is usually the first scaling move for web and API backends.
Caching stores commonly used data closer to where it is needed.
A CDN can cache images, scripts, and public pages near users. An application cache can store frequently read data such as product details, user profiles, feature flags, or computed results.
Caching helps because many systems do the same work again and again. Avoiding repeated work is often cheaper than adding more servers.
Databases often become the main bottleneck as traffic grows.
Common techniques include better indexes, query optimization, read replicas, connection pooling, partitioning, and sharding. These tools are powerful, but they add complexity, so experienced teams usually start with simpler improvements before reaching for sharding.
Not every task needs to finish before the user gets a response.
Sending emails, resizing images, generating reports, updating analytics, processing videos, and running long AI workflows can often happen in background workers. The server accepts the request, stores the work, returns quickly, and lets a worker finish the slow part.
When traffic spikes, the system needs a way to protect itself.
Rate limiting, queues, and backpressure help the system stay alive. Backpressure means slowing down how much work the system accepts. Load shedding means rejecting lower-priority work when the system is overloaded. Graceful degradation means keeping the most important features working even if less important features are temporarily disabled.
Sometimes the best response is not "try to do everything." It is "serve the most important work and reject or delay the rest."
Splitting a server into more services can help when one part has a different scaling need, team owner, deployment pace, or reliability requirement.
But splitting too early creates more network calls, more deployments, more monitoring, and more failure modes. A good rule of thumb: split when the boundary is clear and the pain is real.
Client-server architecture appears in many forms. When looking at any system, ask three questions:
When you visit www.wikipedia.org, the browser sends HTTPS requests for the page and its assets. Some responses may come from caches or CDN edges. Dynamic responses may reach application servers and databases.
Email clients such as Gmail, Outlook, and Apple Mail connect to mail servers. SMTP sends mail between servers. IMAP helps clients sync mailboxes across devices. POP3 still exists, but it is less common for modern multi-device email.
Banking apps use client-server architecture to sign users in, approve actions, show balances, process transfers, and keep audit records. The server side handles the most sensitive work: correct balances, fraud controls, encryption, compliance logs, and access control.
Cloud platforms expose APIs for compute, storage, databases, identity, networking, and monitoring. A deployment tool, SDK, CLI, or application acts as the client. The cloud control plane acts as the server.
AI products usually use client-server architecture because model calls, retrieval, safety checks, and billing need central control. A browser or mobile client should not hold private API keys, query internal databases directly, or manage GPU scheduling. The backend handles those responsibilities and streams results back to the client.
Client-server architecture separates the program asking for work from the system that performs the work and protects shared resources.
For beginners, the simplest mental model is: clients ask, servers decide and respond.
In production, "the server" is often a fleet of processes and managed services, not one machine. Three-tier architecture is the common baseline for web and mobile systems. N-tier designs add specialized layers when scale, security, reliability, or team ownership justifies the extra complexity.
The request-response idea is easy. The hard parts are latency, failures, security, versioning, state, and cost. Good client-server design keeps clients simple, protects shared resources, and makes server behavior easy to observe and change.
10 quizzes