CSE Roadmap

Common tier · about 2 hours · 5 parts

Part 4 of 5 · 2 min read

Why 3-tier usually wins in production

Concrete problems the middle layer actually solves.

Why 3-tier usually wins in production

Think of what happens to the two-worker archive system if the shop's rules change. Only the second worker needs retraining. The clerk at the front desk, and every customer who talks to that clerk, notices nothing.

In plain words: putting business logic in one application server, instead of in every client, means a rule only needs to change in one place. It also means database credentials live in one server, not scattered across every client device. A 3-tier system can also scale the application tier and the database tier separately, adding more application servers without touching the database at all.

A worked example. If the bookstore changes its discount rule, a 2-tier system would need every employee's desktop application updated and reinstalled. A 3-tier system needs only the one application server's code updated. Every client picks up the new rule automatically on its next request.

The key lines. No new code is needed here. This part is about the consequence of the structure already shown in part 2, not a new mechanism.

N-tier architecture

An N-tier architecture generalizes 3-tier to more than three layers, such as adding a separate caching tier or a separate authentication tier. The core idea stays the same: each tier talks only to its direct neighbors, and no tier skips ahead to talk to one further away.

Example: a system with a client, an API gateway, an application server, a cache, and a database is a 5-tier system, built from the same principle as the 3-tier case.

For the curious Tiers are not the three-schema levels

A tier is a layer of a running system, including the client and the network between layers. The three-schema levels from the previous module describe only the database's own internal structure. A 3-tier system's data tier still has its own internal, conceptual and external levels inside it, completely independent of how many tiers sit above it.

Quick notes

  • 2-tier: a client connects directly to a database, with no layer in between.
  • 3-tier: a client, an application server holding business logic, and a database.
  • The application server is the only tier that connects directly to the database in a 3-tier system.
  • 3-tier usually wins in production because business logic and credentials live in one place, and tiers can scale independently.
  • Tiers describe the running system's layers; the three-schema architecture describes the database's own internal structure, and the two ideas are independent of each other.