Learning Objectives

By the end of this chapter, you will be able to:

  • Define client, server, and request response in one sentence each.
  • Group server types by resource they serve.
  • Trace a three tier web request from browser to app to database.
  • Compare client server versus peer to peer on control, cost, and scale.
  • Weigh single point of failure against central benefit with a backup plan.

The core pattern

Every web page, mobile balance check, and email read follows one pattern. A client asks, a server answers. The request response cycle is the contract. The client initiates, the server serves, the network carries the pair.

  • Client: the program or device the user touches. Browser, mobile app, ATM terminal. It holds no master copy. It requests.
  • Server: the powerful program or machine that holds the resource and waits. It listens, authenticates, computes, and replies.

Think of the shop counter. Customer asks, shopkeeper fetches from the store. If the store is locked, every customer waits. That is client server.

Server types: group by what they serve

Serves Server What it holds Everyday example in Nepal
Pages Web server HTML, images, APIs Nginx serving a college site
Messages Mail server Mailboxes, queues Gmail or a company domain mail store
Files File server Shared folders Office shared drive on a LAN
Data Database server Tables, indexes MySQL for a billing system
Logic Application server Business rules and transactions Core banking application that checks balance and posts debit
Names DNS server Name to IP address map ISP resolver or Google DNS 8.8.8.8
Print Print server Printer queues Office printer shared to 20 PCs

A single physical machine can run several logical servers. What matters is the role, not the box.

How it moves: request response

  1. Client sends request: for example GET https://example.com/ with headers and credentials.
  2. Server processes: authenticate, check cache, run logic, query database.
  3. Server sends response: status plus payload such as HTML or JSON.
  4. Client renders or stores the result.
sequenceDiagram
  participant C as Client browser or app
  participant S as Server
  C->>S: Request GET homepage with token
  S->>S: Authenticate and build response
  S-->>C: Response 200 OK plus HTML or JSON
  C->>C: Render to user

Latency is time from step 1 to step 4. Scale is how many such cycles per second the server can finish without queue.

Two tier versus three tier: where logic lives

Tiering Where logic lives When to use Risk
Two tier Client talks directly to database Small office, one app, tight LAN Logic duplicated in every client, harder to secure and update
Three tier Presentation tier in client, logic in application server, data in database server Web and banking at scale More moving parts, needs load balancing and careful deployment

Most Nepali banking and e commerce run three tier. The app on your phone never talks to the database. It talks to an application server, which talks to the database after checking your token and limits.

flowchart LR
  P[Presentation: browser or app] --> A[Application tier: rules]
  A --> D[Data tier: database]

The split lets each tier scale independently. Add more application servers for more users without touching the database.

Client server versus peer to peer

Aspect Client server Peer to peer
Control Central on server Distributed, each peer is equal
Security Easier centrally, one policy Each peer secures itself
Backup Central, one schedule Each peer must be backed up
Cost Server plus admin is dear Cheap at small size
Scale Scales with stronger or replicated servers Suits small or temporary sharing
Example Websites, online banking, corporate mail Home file share, BitTorrent, local sync

Neither is always better. Client server is the default for anything that needs audit, backup, and control.

Self-check

Advantages and limits

Central data, single policy, one place to back up and patch. Shared resource, so a modest client can use a powerful server.

Limits are real: server is a single point of failure unless replicated, overload slows every client, and a skilled admin is required. The answer is not to avoid servers but to plan redundancy, queue limits, and monitoring.

Nepal worked example: campus result portal on 2081-11-10 (NPR)

A TU affiliated campus in Kathmandu must publish BS 2081 final results for 8,000 students. Peak is 2,000 concurrent parents and students in the first 30 minutes on 2081-11-10. The IT lead prices a three tier setup for that day.

  • Load estimate: 2,000 concurrent, each result page is 40 KB HTML plus 60 KB images, fetched twice per user on average. Data = 2,000 times 100 KB times 2 = 400 MB served in 30 minutes.
  • Option budget: one application server at Rs 35,000 per month rental, one database server at Rs 25,000, one load balancer at Rs 8,000, plus bandwidth at Rs 6 per GB. Bandwidth cost for peak = 0.4 GB times Rs 6 = Rs 2.4, negligible. Servers for the result month = Rs 68,000.
  • Without replication, one web server would queue. With two application instances behind the balancer, each handles 1,000 concurrent, queue drops, and failure of one still serves half the users.

Decision: three tier with a second application instance costs Rs 35,000 extra but prevents a headline failure when results drop. Figures are illustrative, but the sizing logic of concurrent times payload times requests is how a campus should size before publishing, not after.

Example 1: On 2081-11-10 treat the portal as an audit event. Ask: does the application tier log every marks read with timestamp and token, does the database tier have a read replica, and can you restore the result set to a known time if a correction is posted? If not, centralisation concentrates risk, not control.

Example 2: On 2081-11-10 treat the portal as a service surge. Ask: how many result pages per minute must each tier sustain, what is the single point of failure, and what is the fallback page if the database stalls? Measure success by still serving on the first 15 minutes, not by peak capacity on paper.

Summary

  • Client asks, server holds and answers, request response is the cycle.
  • Group servers by resource, not by vendor name.
  • Two tier is simple and cheap for small LANs. Three tier separates presentation, logic, and data for scale and security.
  • Central benefit trades against single point of failure and overload unless you replicate and monitor.

Key Takeaways

  • The internet is client server by default.
  • A request without authentication is a risk, not a feature.
  • Tiering decides where you scale and where you patch.
  • Peer to peer is not weaker, it is wrong for work that needs central backup and audit.

Discussion Questions

  1. Which tier would you replicate first when user count doubles: presentation, application, or data, and why?
  2. When is peer to peer cheaper and still acceptable?
  3. What turns a server from a single point of failure into an available service?

Exercises

Short answer

  1. Define client and server with one example each distinct from browser and web server.
  2. What is request response with its four steps?
  3. List four server types by resource served.

Long answer

  1. Diagram client server request response, explain two tier versus three tier with a Nepali banking or campus example, and compare with peer to peer on control, security, backup, cost, and scale.
  2. Size a result publication on 2081-11-10 for 2,000 concurrent users with payload and request math, justify three tier with replication, and compute offered load versus capacity in requests per second with an NPR monthly cost table.