Client–server architecture splits an application between clients that request services and servers that provide them. Two-tier links clients straight to a database; three-tier inserts an application tier — the design behind web, banking and e-governance systems.
High-yield 50 minSyllabus: “Two-tier and three-tier client server architectures”
Mark as
The idea in one minute
Think of a restaurant. In a two-tier restaurant you walk into the kitchen yourself and tell the cook exactly what to fetch from the store-room — fine for a tiny café, chaos with 500 customers. A three-tier restaurant adds waiters: you (presentation) talk only to a waiter (application tier) who knows the menu rules and passes orders to the kitchen and store-room (data tier). Customers never touch the store-room, rules live in one place, and you hire more waiters when the crowd grows.
Key points — the night-before list
Client = initiates requests and presents results; server = listens and provides the service; middleware = software glue between them (ODBC/JDBC, RPC, message queues).
Two-tier: client ↔ database server. UI + business logic on a fat client (or logic in stored procedures = fat server). Simple, but scales to only about a hundred users.
Three-tier: presentation (client) → application / business logic (middle tier, application server) → data (DBMS). Business rules live in the middle tier.
3-tier gains: scalability (connection pooling, load-balanced app servers), security (clients never reach the DB), maintainability (change rules once). Costs: complexity and an extra network hop.
Thin client = presentation only (a browser); thick/fat client = presentation + logic (+ local data). A web application is 3-tier with a thin browser client.
N-tier splits the middle further (web tier, business tier, EIS tier in Java EE); microservices = many small, independently deployable services, each owning its data.
Client–server is centralised and asymmetric; in peer-to-peer every node is both client and server, so capacity grows with the number of peers.
RPC/RMI: the client stub marshals arguments; the server stub (skeleton) unmarshals and calls the procedure. MOM (IBM MQ, MSMQ, RabbitMQ) passes messages asynchronously via queues.
01Clients, servers and middleware
A client is a program that initiates a conversation: it sends a request for some service and then presents the result to the user. A server is a program that waits for requests — it listens on a known network address and port — performs the service and returns a response. The words describe roles in a conversation, not types of machine: one computer can run a web server and a browser at the same time.
One request followed by its reply is a request–response cycle. The client always speaks first; a server never contacts a client it has not heard from. This asymmetry — many clients sharing one service — is what makes a design client–server rather than peer-to-peer.
Between the two sits middleware: software that hides the network and makes a remote service look local. Robert Orfali's famous description is that middleware is the slash in client/server. Database drivers (ODBC, JDBC, ADO.NET providers), remote procedure call (RPC) libraries, message queues and application servers are all middleware.
Characteristic
What it means
Service
The server offers a well-defined service (file, print, database, web, mail); clients consume it.
Shared resources
One server serves many clients at once and arbitrates their access to shared data and devices.
Asymmetrical protocols
Many-to-one: clients always initiate; the server waits passively for requests.
Transparency of location
The client need not know where the server physically runs; middleware hides it.
Message-based exchange
Client and server interact only through request and reply messages, never shared memory.
Encapsulation of services
The server decides how to do the job and can be upgraded without changing clients.
Scalability
Horizontal: add more clients. Vertical: move the server to a bigger machine or add servers.
Integrity
Data and business code are kept centrally, so they are easier to protect, back up and keep consistent.
Classic characteristics of client–server systems (after Orfali, Harkey and Edwards)
Roles, not machines
Client = initiator and presenter; server = listener and provider. A program can play both roles: a web server is a server to browsers but a client of the database server it queries.
02Two-tier architecture
In a two-tier (2-tier) system the client application talks directly to a database server. Tier 1 is the user's PC running a desktop program built with a tool such as Visual Basic, Delphi, Oracle Forms or PowerBuilder; tier 2 is the DBMS (Oracle, SQL Server, MySQL) on a server. The client sends SQL statements across the network through a driver and receives rows back.
Where does the business logic live — rules such as an applicant's annual income must not exceed ₹3 lakh for the EWS category? Usually on the client, mixed with the user-interface code. Such a client is a fat client (thick client). Alternatively the rules are written as stored procedures and triggers inside the database; then the server is 'fat' and the client thinner, but the system is still two-tier because there is no separate application tier.
JavaA fat client: database credentials, SQL and business rules all live on the user's PC
// Inside the desktop client (tier 1): it opens its own database connection
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@dbserver:1521/KSHB", "clerk01", password);
PreparedStatement ps = con.prepareStatement(
"SELECT income FROM applicants WHERE app_no = ?");
ps.setInt(1, appNo);
ResultSet rs = ps.executeQuery();
if (rs.next() && rs.getLong("income") > 300000) { // business rule coded in the client
JOptionPane.showMessageDialog(null, "Not eligible for EWS");
}
Fat client (logic on the client)
UI, business rules and SQL all inside the desktop program
A rule change means rebuilding and reinstalling the program on every PC
Raw rows cross the network so the client can process them
Typical of early Visual Basic / PowerBuilder front ends
Fat server (logic in stored procedures)
The client holds only the UI and calls procedures
Rules change in one place — the database
Less network traffic: the server does the work and returns results
Ties the application to one DBMS's procedural language (PL/SQL, T-SQL)
Strengths of two-tier
Weaknesses of two-tier
Simple to design, build and deploy with rapid application development (RAD) tools
Poor scalability — every client holds its own database connection
Fast for a small group of users on one LAN
Maintenance — logic must be redeployed to every desktop
Fewer machines and software layers to manage
Security — clients hold database credentials and reach the database directly
Good for departmental applications (roughly up to 100 users)
Chatty SQL over a WAN is slow; little load balancing or fault tolerance
Watch out
Two-tier is not 'wrong'. A 10-user office application on one LAN is cheaper and simpler as two-tier. The problems appear with many users, wide-area networks and frequently changing business rules.
A three-tier (3-tier) system inserts an application tier (the middle tier) between the client and the database. Each tier has one job and can run on its own machine:
Tier
Runs on
Responsibility
Typical technology
1. Presentation (client) tier
User's PC, phone or browser
Display data, collect input, simple input checks
HTML/CSS/JavaScript, mobile app, desktop GUI
2. Application (business-logic / middle) tier
Application server(s) in the data centre
Business rules, workflow, validation, transactions, security checks
Store, retrieve and protect data; integrity constraints
Oracle, MySQL, SQL Server, PostgreSQL
The client never sees the database. It asks the middle tier for a business operation — submit application, book unit — and the middle tier decides which SQL to run. Because the client holds only the user interface it is a thin client; a web browser is the thinnest client of all because nothing has to be installed.
The middle tier usually runs inside an application server, which supplies services every application needs: a pool of reusable database connections, transactions, security, caching, messaging and clustering. Before the web era, TP monitors (transaction-processing monitors) such as IBM CICS and Tuxedo played this role for banks and airlines.
Scalability — thousands of clients share a small pool of database connections, and more application servers can be added behind a load balancer.
Security — database credentials live only on the application server; a firewall can admit only the middle tier to the database.
Maintainability — a business rule changes in one place; no desktop reinstall.
Flexibility and reuse — one business tier can serve a web site, a mobile app and an ATM network; the UI or the database can be replaced independently.
Reliability — replicated application servers remove the single point of failure in the logic tier.
PSC favourites
In 3-tier client–server, which tier runs on the client? → Presentation. Where does the business logic lie? → the middle tier (not the client, not the database server). Why use a middle tier? → to enforce business rules and isolate the client from data logic.
The price is complexity: more components to build, deploy and monitor, an extra network hop on every request, and harder debugging across tiers. For a small single-office application these costs can outweigh the benefits.
04Two-tier vs three-tier at a glance
Aspect
Two-tier
Three-tier
Structure
Client ↔ database server
Client ↔ application server ↔ database server
Business logic
On the client (fat client) or in stored procedures
In the middle tier
Client type
Thick / fat
Thin (often just a browser)
Database connections
One per client
Pooled and shared by the middle tier
Scalability
Tens to about a hundred users
Thousands to millions (add application servers)
Security
Clients reach the database and hold credentials
Database hidden behind the middle tier and a firewall
Maintenance
Redeploy to every client for a rule change
Change the server once
Network traffic
Many SQL round trips; raw rows cross the network
One request per business operation; only results cross the WAN
Development
Simple and quick (RAD tools)
More complex; needs an application server
Examples
VB or MS Access front end on a LAN database
Web portals, internet banking, railway reservation, e-governance
Mnemonic P-A-D
Presentation, Application, Data — from the user's screen down to the disk. The middle letter is where the rules are.
Try the Client–server tiers tool on this page: switch between its 2-tier and 3-tier modes and watch where each request travels and how many database connections stay open.
05N-tier, web applications and microservices
A single-tier (1-tier) application keeps UI, logic and data on one machine — a stand-alone MS Access database or a spreadsheet macro. At the other end, n-tier (multi-tier) architecture splits the middle tier further when one box can no longer do everything.
Java EE (now Jakarta EE) names four tiers: the client tier (browser or application client), the web tier (servlets and JSP in a web container), the business tier (Enterprise JavaBeans in an EJB container) and the EIS tier (enterprise information systems — databases, ERP, mainframes).
A typical public portal is deployed as browser → load balancer → web server (static files, TLS) → application server (PHP, JSP, ASP.NET) → cache (Redis) → database. Whether you call that three tiers or six depends on what you count; exam questions normally treat web server + application logic as the single middle tier.
Microservices push the idea to its limit. Instead of one large middle tier (a monolith), the business logic is split into small services — applications, payments, notifications — each running in its own process, owning its own database, deployed independently and talking to the others over HTTP/REST, gRPC or message queues. An API gateway gives clients a single entry point. Microservices descend from service-oriented architecture (SOA).
Monolithic middle tier
One deployable unit holding all business logic
Simple to develop, test and deploy at first
Scale by copying the whole application
One bug or slow module can affect everything
Microservices
Many small services, each with one business capability
Independent deployment, technology choice and scaling
Each service owns its data; communication over the network
Harder to operate: monitoring, network failures, distributed data
Tier ≠ layer
A layer is a logical slice of code (UI layer, business layer, data-access layer). A tier is a physical deployment unit — a separate process or machine. A program with three layers running entirely on one PC is still a one-tier application.
06Thin vs thick clients; client–server vs peer-to-peer
Thin client
Holds only the presentation; logic and data are on servers
Little or nothing to install (browser, remote-desktop terminal)
Central updates; easy to manage hundreds of seats
Useless without the network; every action needs the server
Thick (fat) client
Holds presentation and business logic, sometimes local data
Installed program (desktop accounting, Oracle Forms client)
Responsive and can work offline or with less server load
Every update must reach every PC; harder to secure
Between the two sits the rich client: a browser application that downloads a lot of JavaScript (Gmail, Google Docs) and does much of its work locally, yet installs nothing. It is still thin in the deployment sense but thick in behaviour.
In peer-to-peer (P2P) systems there is no permanent server: every node — a peer — is both client and server, requesting data from and serving data to others. BitTorrent file sharing, blockchain networks and early Skype work this way.
Aspect
Client–server
Peer-to-peer
Roles
Fixed: clients request, servers serve
Every peer does both
Control
Centralised; easy to secure, audit and back up
Decentralised; hard to administer
Scalability
Server capacity is fixed — more clients mean more load
Self-scaling — each new peer adds capacity
Failure
Server is a single point of failure unless replicated
No single point of failure
Cost
Needs powerful, managed servers
Uses the peers' spare resources
Examples
Web, e-mail, banking, DNS
BitTorrent, blockchain, early Skype
File of F bits sent to N clients; server upload rate uₛ;
each peer's upload rate u; slowest client's download rate dₘᵢₙ
Client–server : D_cs ≥ max( N·F / uₛ , F / dₘᵢₙ )
Peer-to-peer : D_p2p ≥ max( F / uₛ , F / dₘᵢₙ , N·F / (uₛ + N·u) )
Minimum time to distribute a file: client–server time grows linearly with N, P2P time levels off (Kurose & Ross)
07Middleware: database drivers, RPC and message queues
Middleware lets the tiers talk without each program re-implementing networking. The main families are:
Kind
What it does
Examples
Database middleware
One standard API plus a driver per DBMS, so code can talk to any database
ODBC (Microsoft, 1992), JDBC (Java, 1997), ADO.NET providers, OLE DB
Remote procedure call (RPC)
Call a procedure on another machine as if it were local
Sun ONC RPC, DCE RPC, Java RMI, gRPC
Message-oriented middleware (MOM)
Send messages through queues; sender and receiver need not run at the same time
IBM MQ (MQSeries), Microsoft MSMQ, RabbitMQ, Apache Kafka
Object request brokers
Invoke methods on remote objects across languages
CORBA (OMG), DCOM
TP monitors
Manage transactions, load balancing and recovery for the middle tier
IBM CICS, Tuxedo
Web services / APIs
Expose services over HTTP with XML or JSON
SOAP + WSDL + UDDI, REST with JSON
How a remote procedure call works
Call the stub
The client calls what looks like a local procedure, e.g. getBalance(acc). The call really goes to a client stub generated from the interface definition.
Marshal
The stub packs the procedure identifier and arguments into a network message — marshalling (serialisation).
Transport
The RPC run-time sends the message to the server machine over TCP or UDP.
Unmarshal and execute
The server stub (called the skeleton in Java RMI) unpacks the arguments and calls the real procedure.
Reply
The return value travels back the same way; the client stub unmarshals it and returns it to the caller, which was blocked waiting — RPC is normally synchronous.
Message queues make communication asynchronous. An ATM switch can drop a withdrawal message into a queue even if the core-banking host is briefly down; the message is delivered when the host returns (store-and-forward). Queues also absorb bursts of load and decouple producers from consumers.
PSC favourite
In Java RMI the stub is the client-side proxy that intercepts a method call and talks to the remote server; the skeleton is its server-side partner. SOAP messages are written in XML; WSDL describes a web service's interface; UDDI is the XML-based registry for publishing and locating web services.
08Real systems mapped to tiers
Internet banking — browser (presentation) → the bank's web and application servers enforcing limits, OTP checks and fund-transfer rules (logic) → core-banking database (data).
ATM network — the ATM is a thin client (screen, card reader, cash dispenser); the ATM switch / transaction server checks the PIN and limits and routes the request (logic); the core-banking host holds balances (data). Messages often travel through queues.
Railway reservation — millions of browsers and apps → load-balanced application servers → seat-inventory database, where each booking must be one atomic transaction.
E-mail — Outlook or Thunderbird (thick client) talking to a mail server is classic client–server; webmail such as Gmail in a browser is three-tier.
One example threads through this whole module: a housing-board portal where citizens and staff use a browser form (presentation), PHP, JSP or ASP.NET code checks eligibility and allots units (application tier), and MySQL or SQL Server stores users and housing schemes (data tier). The server-side topics build exactly this application in each technology so you can compare them line by line.
Step through · One request through a load-balanced 3-tier portal
step 1 / 8
Step 1: HTTPS POST /apply (form data)
The citizen submits the application form. Only the presentation tier runs on the user's machine; it knows nothing about tables or SQL.
Worked examples
Try the problem first, then reveal the working one step at a time.
EX 1Chatty SQL over a WAN
A branch office's loan screen needs 6 SQL statements. In the 2-tier design the branch PC sends all 6 to the head-office database over a WAN with round-trip time (RTT) 50 ms. In the 3-tier design the PC sends one request to an application server at head office (same 50 ms RTT) and the application server runs the 6 statements against the database over the data-centre LAN (RTT 0.5 ms). Ignoring processing time, how long does each design wait on the network per screen?
EX 2Why connection pooling scales (Little's law)
A citizens' portal has 3,000 logged-in users. Each user sends on average one request every 20 s, and each request holds a database connection for 40 ms. (a) How many database connections does a 2-tier design need if every client keeps its own? (b) In a 3-tier design with pooled connections, how many are busy on average? (c) With 2 application servers each holding a pool of 20, what is the average pool utilisation?
EX 3Client–server vs peer-to-peer distribution time
A 100 MB installer must reach N = 100 users. The server's upload rate is 100 Mbps, each user can upload at 10 Mbps, and the slowest user downloads at 50 Mbps. Find the minimum distribution time for client–server and for P2P.
EX 4Designing an ATM system in tiers
Map an ATM cash-withdrawal system to tiers and decide where the bank's rule 'at most ₹25,000 per card per day' should be enforced.
Practice session
Work each problem on paper first, then check. Marking one solved earns 10 XP.0/5 solved
Q1
An online railway-reservation system uses browsers, Apache + Tomcat running servlets and JSP, and an Oracle database reached through JDBC. Name the three tiers, say what runs in each, and identify the middleware.
Q2
Four application servers each keep a pool of 25 database connections, and each query holds a connection for 20 ms. (a) What is the maximum query rate the pools can sustain? (b) What happens if demand reaches 6,000 queries per second?
Q3
Classify each as a thin, thick or rich client and justify: (a) a browser showing a server-rendered PHP page; (b) a desktop accounting package that runs its own reports and sends SQL to a central server; (c) a remote-desktop (RDP/Citrix) session; (d) Google Docs in a browser.
Q4
A 2-tier billing application has its business rules coded in a Visual Basic client installed on 200 PCs. The GST rate changes. Compare the effort of applying the change in (a) the current design, (b) a 'fat server' redesign using stored procedures and (c) a 3-tier redesign.
Q5
Give four reasons why a public citizen portal must not let browsers connect directly to its database, even if the JavaScript could open such a connection.
Exam traps
Tier vs layer: tiers are physical (separate processes or machines), layers are logical code divisions. A three-layer program on one PC is a one-tier application.
In 3-tier the business logic is in the middle tier — not 'divided between client and server' and not in the database server.
Putting the rules in stored procedures does not make a system three-tier; it is a two-tier fat-server design.
Some books count a web application as four tiers (browser, web server, application server, database). If only 'three' is offered, treat web + application server as the single middle tier.
'Thin client' describes how little logic the client holds, not cheap hardware; a browser running a heavy JavaScript application is a rich client.
Middleware is software (ODBC, RPC, MOM), not a hardware tier — although some texts loosely call the application server itself 'middleware'.
Quiz — KPSC style
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.