Learning Objectives

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

  • Define client server architecture and request response.
  • Explain client and server roles and list common server types.
  • Compare two tier and three tier designs and peer to peer.
  • Identify risks such as single point of failure and mitigations.
  • Map the model to Nepali retail, hotel, and supply chain systems.

The Core Pattern

Client server architecture separates asking from serving. A client requests a resource, a server hosts and controls it, and the network carries request and response. This lets many low cost devices share few well managed central resources. Your POS app or mobile banking app is a client, the data center that returns your balance is a server.

Grouped Framework: Three Views

View 1: Roles - Who Asks and Who Serves

  • Client - user facing, numerous and lightweight, handles display and input, for example rendering a product page or reading a barcode.
  • Server - dedicated, always on, owns data and rules, serves thousands of clients.
Server type Provides Example
Web server Pages over HTTP Nginx for shop.com.np
Application server Business logic Pricing and booking rules
Database server Stored data MySQL for stock and guests
Mail server Email Company mail on own domain
File server Shared folders Showroom design files
DNS server Name to IP ISP or company DNS
Print server Printer queue Branch invoice printer

View 2: Interaction - Request Response Cycle

  1. Client sends request, such as GET homepage or POST login.
  2. Server authenticates, processes, may call other servers.
  3. Server returns response with status and data.
  4. Client renders result.
sequenceDiagram
  participant C as Client (POS or browser)
  participant S as App server
  participant D as Database
  C->>S: GET product 1182
  S->>D: Query stock and price
  D-->>S: 12 units, NPR 4,500
  S-->>C: 200 OK + data
  C->>C: Display

Count requests per minute and capacity per tier to plan cost and scale.

View 3: Structure - How Many Tiers

  • Two tier - client talks directly to database. Simple for a single shop desktop billing, but logic lives in client and security is harder.
  • Three tier - presentation (browser or app), application (rules), data (database). Most banking and hotel systems use this because each tier can be secured and scaled separately.
  • Beyond three tier - APIs, cache, CDN, but the idea stays: separate concerns so a mobile app change does not force a database rewrite.

Client Server vs Peer to Peer

Aspect Client server Peer to peer
Control Centralised on server Equal peers
Security Central policy, easier audit Each peer secures itself
Backup Central backup Each peer backs up
Cost Higher server and admin cost Cheap
Scale Scales with stronger servers Small groups
Example E-commerce, banking, hotel PMS Direct file share, BitTorrent

A retail chain uses client server for stock, but designers may share a large photo set peer to peer when offline, then sync later.

Advantages, Risks, Mitigations

Advantages: central data and backup, one update reaches all clients, pooling lets small clients use powerful servers.

Risks: single point of failure, overload during peak, higher cost and skill need.

Mitigations: two app servers behind load balancer, replicated database, daily offsite backup with restore tests, cache and CDN, rate limiting during peak.

Nepal BBM Angle: Retail, Hotel, and Supply Chain

Retail (valley chain). Counter POS is client, Kathmandu hosted application holds pricing logic, database holds stock by branch. When a customer buys in Asan, POS requests application, which updates stock and posts to central database. Managers see it on a web dashboard, another client to same tiers. During Dashain peak, scale the application tier, not every branch PC.

Hotel (Pokhara, 50 rooms). Booking app is client, application checks inventory, database returns availability. Housekeeping tablets report room status as separate clients. Central control is required for rates and audit, so peer to peer is unsuitable.

Supply chain (Birgunj to Kathmandu). Scanners POST each carton to application, which validates against purchase order in database. Vans report GPS as clients. The server is the authority, not a van.

Worked Example: NPR Capacity on BS 2081

Scenario dated Poush 20, 2081. A retailer expects 600 requests per minute at peak, each needs 120 ms app processing. A small app server handles 400 threads at NPR 18,000 per month, a larger at 800 threads for NPR 32,000.

Arrival rate = 600 per minute = 10 per second. Service time = 0.12 seconds. Average concurrent = 10 x 0.12 = 1.2. With 5x burst for festival, about 6 concurrent. One small server covers this. Two small cost NPR 36,000, one large NPR 32,000. Choose one small plus a warm standby for failover rather than one large, because redundancy avoids single point of failure and you can scale per tier.

Self-Check

Check your understanding 1. Hotel booking app, which is client and server? App and browser are clients, booking application and database are servers. 2. Why three tier for a chain? Rules are central, clients need no direct database access, each tier scales separately. 3. Peer example vs client server in same company? Share video direct peer to peer between designers, POS syncing to central stock via client server. 4. How to mitigate single point of failure cheaply? Warm standby, replicated DB, backup tests on critical tier.

Try This

On Baisakh 1, 2082 a flash sale expects 5,000 checkouts in one hour. Each checkout makes 4 requests, each 150 ms app time. Server has 300 threads at NPR 20,000 per month.

  1. Requests per second = 5,000 x 4 / 3,600 = about 5.56.
  2. Average concurrent = 5.56 x 0.15 = about 0.83, well under 300.
  3. On average one server is enough, but traffic bursts. You still add a second for failover because losing checkouts at NPR 2,000 each far exceeds NPR 20,000 for the extra server.
Answer sketch Average shows spare capacity, but bursts and failure risk justify redundancy. Protect the tier that holds the sale.

Summary

Client server separates asking and serving via request response. Two tier links client to database, three tier adds an application tier for security and scale. Client server centralises control at higher cost, peer to peer is cheap but dispersed. Resilience comes from redundancy, replication, and per tier planning.

Key Takeaways

  • Client initiates, server responds.
  • Request response is the unit of scale.
  • Two tier is client to DB, three tier adds application.
  • Centralisation improves control but needs duplication.
  • Price and plan per tier, not per machine.

Exam-Style Questions

Short answer

  1. Define client and server with one Nepali example each.
  2. What is request response?
  3. List four server types.

Long answer

  1. Explain client server with diagram and compare with peer to peer.
  2. Describe two tier and three tier with an online retail or hotel example.