Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Client–server database architecture

Client–server database architecture explains how database clients, application/middleware, and DBMS servers are arranged, how requests flow, and how design choices (two-tier vs three-tier, connection pooling, caching, load balancing, replication) affect performance, scalability and availability.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Client–server database architecture is the standard way applications access a DBMS: engineers design the client, middleware and server components to meet latency, throughput, scalability and availability targets. Understanding how requests travel, where to place logic (client vs middleware vs DB server), and how to balance load, cache, pool connections and fail over is essential in building reliable, high-performance database-backed systems.

Key ideas

Start from first principles: a system that serves requests has a requester, a service provider, and a transport.

  • Client — the software component that initiates a request to the database (for example, a web server, a desktop app or a mobile app). The client sends requests and receives responses; it may be a thin client (mostly UI, little logic) or a fat (thick) client (containing application logic and sometimes business rules).

  • Server — the software that accepts requests and performs work (here, the DBMS server). The DBMS server executes queries, enforces transactions and accesses storage.

  • Middleware — software between client and server that can perform connection pooling, caching, authentication, business logic, and query routing. Examples: application servers, web servers, API gateways. Middleware is optional but common in three-tier systems.

  • Two-tier (client–server) — architecture with direct communication: client ↔ DBMS server. Client contains application logic and issues SQL directly to the DBMS.

  • Three-tier — architecture with client → application/middleware → DBMS server. The middle tier holds business logic, connection management, caching, and often improves scalability and security.

  • Connection pooling — a technique where a set of pre-established DB connections are reused by multiple client requests to avoid repeated connection setup and teardown costs.

  • Caching (at middleware or client) — storing frequently-read data close to the client or in middleware to reduce load on the DBMS and lower latency.

  • Load balancing — distributing incoming requests across multiple database servers or replicas to increase throughput and availability. In single-leader databases, write requests must go to the primary; reads can be balanced across replicas (mind read-staleness with async replication).

  • Replication — keeping copies of the database on multiple servers. Replicas can be synchronous or asynchronous and are used for read-scaling and failover. Synchronous replication increases write latency (commit must wait for replicas); asynchronous replication avoids that cost but introduces replica lag and potentially stale reads.

  • Sharding (horizontal partitioning) — splitting the dataset across multiple servers by key-range or hash to scale write and storage capacity.

  • Stateless vs stateful server — a stateless server does not keep client-specific session state between requests (each request contains required context); a stateful server maintains session state. Stateless servers are easier to load-balance and scale.

  • Transaction manager, storage manager, query processor — internal DBMS components: the transaction manager enforces atomicity and isolation (ACID), the recovery/log manager with the storage subsystem ensures durability, the storage manager handles pages and buffers, and the query processor parses and plans queries; these remain on the server in client–server architecture (refer to other topics for deep detail like concurrency control and ARIES/WAL recovery).

Exact statements and commonly asked derivations:

  1. Little's law (queueing principle) — under steady-state and for a stable queue, average number in system L = arrival rate λ × average time in system W. Assumptions: arrivals and service processes need not be Poisson; system must be stable (average arrival rate equals average departure rate). Derivation universities expect: consider time T, completed jobs C(T), sum of times spent by jobs approximates C(T)·W, average number L ≈ (C(T)·W)/T, but C(T)/T → λ, so L = λ·W. Draw a timeline showing jobs entering, residing, and leaving.

  2. Server utilization and throughput relations — for a single-server FIFO queue: utilization ρ = λ·S where S is the mean service time per job. For stability require ρ < 1. Show algebra: average service demand S (s), arrival rate λ (jobs/s) ⇒ server busy fraction is λ·S.

  3. Network transfer time model — time to transfer a payload size (bytes) ≈ latency + payload_size / bandwidth. Precise term: total time = round-trip latency (or handshake cost) + transmission time. Assumptions: ignore packet loss and protocol overhead for basic estimate. Draw a diagram: client —(latency)→ server, server processing time, response back.

  4. Availability of a repairable server — steady-state availability A = MTBF / (MTBF + MTTR). Assumptions: one failure mode, constant rates, exponential repair/failure if deriving from rates. For n identical independent replicas in parallel, availability of at-least-one-up = 1 − (1 − A)^n (assumes independent failures).

Diagram to draw for an exam (describe precisely):

  • Draw three stacked boxes left-to-right: Client; Network; DBMS Server internals. Inside DBMS Server box, draw sub-boxes labeled Listener, Connection Handler, Query Parser, Query Optimiser, Execution Engine, Buffer Manager, Transaction Manager, Log/Storage. If a connection pool exists, place it in the middleware box (application server), not inside the DBMS server box. Draw arrows: Client → Listener (TCP connect), Listener → Connection Handler → Query Parser → Optimiser → Executor → Buffer Manager → Disk I/O and Log, then back to client. Label network latency on Client↔Listener arrow and label disk I/O time inside storage.

Notes on trade-offs (exact wording):

  • Two-tier places application logic on clients; simpler but harder to scale and secure. Three-tier centralises business logic in middleware; easier to scale, manage and cache and to control connections.
  • Thin clients improve manageability; fat clients reduce server load but increase client maintenance.

Where this topic connects to others: concurrency control, recovery and transaction handling remain server-side (see Lock-based and timestamp-based concurrency control; Log-based recovery, WAL and checkpoints, ARIES), and replication/sharding links to Distributed databases and Parallel database architectures.

Formulas

L = λ · W — L: average number of requests in the system (dimensionless count), λ: average arrival rate (requests · s⁻¹), W: average time a request spends in system (s). Applies under steady-state (Little's law).

ρ = λ · S — ρ: server utilisation (fraction, dimensionless), λ: arrival rate (requests · s⁻¹), S: mean service time per request (s). Applies to single-server queue; for stability require ρ < 1.

T_total = T_network + T_server = latency + size / bandwidth + S — latency: network round-trip latency (s), size: payload size (bytes), bandwidth: link bandwidth (bytes · s⁻¹), S: server processing time (s). Use for approximate request–response time estimates.

A = MTBF / (MTBF + MTTR) — A: availability (fraction), MTBF: mean time between failures (s), MTTR: mean time to repair (s). Applies for repairable systems with single failure mode in steady-state.

A_repl = 1 − (1 − A)^n — A_repl: availability of at-least-one-up with n identical independent replicas, A: single-node availability (fraction), n: number of replicas (integer). Assumes independent failures.

X = λ (steady state) — X: throughput (completed requests per second), equals arrival rate when system is stable (requests · s⁻¹).

Worked examples

Example 1 — simple response-time estimate Question: A client sends a 50 KB query and expects a 200 KB result. Network round-trip latency is 30 ms, bandwidth is 10 Mbps, and server processing time S is 60 ms. Estimate total response time. Steps:

  1. Convert units: 10 Mbps = 10 × 10^6 bits/s = 1.25 × 10^6 bytes/s.
  2. Total payload size = 50 KB + 200 KB = 250 KB = 250 × 1024 = 256000 bytes. Use 250000 bytes if KB=10^3 — here use 250000 bytes for simplicity. (State your KB definition in an exam.)
  3. Transmission time = size / bandwidth = 250000 bytes / (1.25 × 10^6 bytes/s) = 0.20 s = 200 ms.
  4. Total time T_total = latency + transmission + S = 30 ms + 200 ms + 60 ms = 290 ms. Answer: 290 ms.

Example 2 — Little's law for concurrent requests and throughput Question: A DB server receives on average 120 queries per second and average query time (W) is 0.08 s. What is the average number of concurrent requests in the system and is the server utilisation ρ if average service time S is 0.007 s? Steps:

  1. Use Little: L = λ · W = 120 s⁻¹ × 0.08 s = 9.6 requests.
  2. Throughput X ≈ λ = 120 requests/s (steady state).
  3. Utilisation ρ = λ · S = 120 × 0.007 = 0.84 (84%). Since ρ < 1, system is stable but highly utilised. Answer: Average concurrent requests = 9.6; Utilisation = 84%.

Example 3 — benefit of connection pooling (numeric) Question: A DB connection setup (auth + handshake) takes 150 ms each time. Each query execution time (after connection is ready) is 20 ms. 50 clients each execute one query per minute. Compare total DB server CPU time per minute with and without pooling assuming pooling reuses 10 shared connections. Steps:

  1. Without pooling: each of 50 queries needs connection setup: per-minute overhead = 50 × 150 ms = 7500 ms = 7.5 s. Query execution total = 50 × 20 ms = 1000 ms = 1.0 s. Total = 8.5 s CPU-equivalent per minute.
  2. With pooling (10 persistent connections): assume connections established once and reused; per-minute connection setup cost ≈ 0. Query execution still 1.0 s. Total ≈ 1.0 s per minute. Answer: Without pooling 8.5 s/min, with pooling ≈ 1.0 s/min — pooling saves ~7.5 s/min of DB-side work.

Common mistakes

  • Saying three-tier is always slower than two-tier — it adds network hops but often improves throughput and scalability via pooling and caching.
  • Using Little's law without checking steady-state assumption — Little's law does not apply when arrival rate exceeds service capacity (system not stable).
  • Treating availability of replicas as simply n × A; correct formula is 1 − (1 − A)^n under independence assumption.
  • Forgetting to convert units (bits ↔ bytes, ms ↔ s). Always show conversions.
  • Assuming ACID transaction enforcement happens at client; it is the server (transaction manager) that enforces it in client–server DBMS.

For your exam

Types of questions:

  • Definitions and short notes (define client, server, middleware, two-tier vs three-tier, connection pooling). Full marks: precise definitions and short pros/cons.
  • Diagrams (draw a client–server diagram showing listener, connection handler, query processor, buffer manager, disk and network latency). Full marks: correctly labelled boxes and arrows and explanation of each component.
  • Derivations (Little's law explanation or utilising ρ = λ·S). Full marks: statement of assumptions, step-by-step derivation and conclusion.
  • Numericals (compute response time, throughput, utilisation, availability). Full marks: unit conversions, formulas, substituted numbers, final numeric answer with units.
  • Short design questions (when to use two-tier vs three-tier, when to shard or replicate). Full marks: state requirements (scale, security, latency), trade-offs and an architectural recommendation.

Quick check

  1. What is a thin client?
  2. State Little's law in symbols.
  3. How does connection pooling improve DB server scalability? Answers: 1) A thin client is a client that contains mostly UI and little application logic, relying on middleware/servers for processing. 2) Little's law: L = λ · W. 3) Connection pooling reuses established DB connections, removing repeated setup/teardown overhead (authentication, TCP handshakes), lowering per-request cost and allowing more concurrent logical clients for same DB resources.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?