Two Tier Architecture
Two Tier Architecture
Definition
Two-Tier Architecture is a specific client-server design with exactly two layers: Tier 1 (the client) contains both the user interface and the application/business logic, and Tier 2 (the database server) stores data and executes SQL. The client connects directly to the database server, typically via ODBC/JDBC.
How It Works — Business Logic Lives on the Client
A desktop banking application installed on a bank teller's PC contains both the screen forms (UI) and the business rule "a withdrawal cannot exceed the account balance" (application logic), all bundled into Tier 1. This client connects directly to the bank's central database server (Tier 2) to run its SQL queries. There is no middle layer — the client talks straight to the database.
Edge Cases and Pitfalls Specific to Two-Tier
- The "fat client" problem: because business logic lives on every client machine, changing a single business rule (say, changing the maximum withdrawal limit) requires updating and redeploying the application on every client PC — a real maintenance burden as the number of clients grows.
- Connection scaling: each client opens its own direct connection to the database server, so the number of open connections grows linearly with the number of users. At large scale, this becomes a serious bottleneck for the database server — exactly the problem that connection pooling (2.12) and a shared middle tier (2.10) are designed to solve.
- Vendor lock-in risk: tightly coupling application logic directly to one database vendor's driver/dialect (since the client talks straight to it) makes migrating to a different database harder later.
Distinguishing It From Three-Tier (2.10)
The defining difference is where the business logic lives and how many clients connect directly to the database. In two-tier, logic is on the client and every client has its own direct DB connection. In three-tier, logic moves to a middle application-server tier, and that tier — not each individual client — manages (and can pool) the database connections.
Interview Takeaways
- Q: What is the classic drawback of two-tier architecture at scale? Every client needs its own direct database connection and locally-installed business logic, causing high connection overhead on the server and painful software updates across many client machines whenever a rule changes.
- Q: Where does application/business logic live in two-tier architecture? On the client (Tier 1), bundled together with the user interface.