One Tier, Two Tier and Three Tier Architecture

Tier architecture describes how many machines or layers a database request passes through. One tier is local, two tier puts the application on the client, three tier inserts an application server between them.

Concept

Tier architecture counts the layers a request crosses between the user and the stored data. It is a deployment question, and it is entirely different from the three level architecture of Phase 1.

Three level architecture is about abstraction — external, conceptual, internal. Three tier architecture is about deployment — client, application server, database server. Examiners set this trap every year.

One tier architecture

   +----------------------------+
   |  user + application + DBMS |
   |  all on the same machine   |
   +----------------------------+

The user sits directly at the machine holding the database. There is no network in the path. Used for local development, embedded databases inside a single application, and small single user tools.

  • Advantages — simplest possible setup, fastest for one user, no network failure.
  • Disadvantages — no sharing, no remote access, security is only as good as the machine, does not scale beyond one user.

Two tier architecture

   CLIENT machine                    SERVER machine
   +-----------------------+         +---------------+
   | application logic     | network |   DBMS        |
   | user interface        |<=======>|   database    |
   | database driver       |         |               |
   +-----------------------+         +---------------+

   Each client opens its OWN connection to the database.

The application runs on the client and talks directly to the database server. This is the classic client server database application.

  • Advantages — straightforward, fewer moving parts than three tier, direct and therefore low latency.
  • Disadvantages — every client needs database credentials and a driver, business logic is duplicated on every client, updating the application means updating every machine, and the connection count grows with the number of clients.

Three tier architecture

   PRESENTATION        APPLICATION            DATA
   +-----------+      +--------------+     +-----------+
   | browser   |<====>| app server   |<===>|  DBMS     |
   | or thin   |      | business     |     |  database |
   | client    |      | logic,       |     |           |
   +-----------+      | connection   |     +-----------+
                      | pool, auth   |
                      +--------------+

   The client NEVER talks to the database directly.

An application server sits in the middle. It holds the business logic, authenticates users, and owns a small pool of database connections shared by thousands of clients.

  • Advantages — the client needs no database credentials, logic is changed in one place, connection pooling means far fewer database connections, each tier scales independently, and the database can sit in a private network unreachable from outside.
  • Disadvantages — more components to build, deploy and monitor; one extra network hop; the application server becomes a failure point unless it is made redundant.

Comparison

PointOne tierTwo tierThree tier
Layers123
Where the logic livesSame machineOn the clientOn the application server
Client holds DB credentialsNot applicableYes — a real weaknessNo
Database connectionsOneOne per clientA shared pool
Updating the applicationOne machineEvery clientThe server only
ScalabilityNoneLimitedGood
SecurityLocal onlyWeak — database exposed to clientsStrong — database can be private
Typical useLocal tools, embedded databasesInternal desktop applicationsWeb and mobile applications

Example

The same college results system, three ways

 ONE TIER    a lecturer keeps marks in a local database on a
             laptop. Nobody else can see them.

 TWO TIER    a desktop program is installed in twelve offices.
             Each copy holds a database username and password.
             A rule change means visiting twelve machines, and
             anyone who opens the program config sees the
             credentials.

 THREE TIER  a web portal. Students use a browser. The
             application server checks who they are, applies
             the rules once, and uses eight pooled connections
             to serve four thousand students. The database
             accepts connections only from the app server.

Where n tier goes next

Beyond three tiers the same idea repeats: a load balancer in front, a caching tier, a reporting replica, a message queue for slow work. The principle never changes — separate responsibilities so each can be secured, scaled and changed on its own.

Common mistakes

  • Confusing tier with level. Levels are abstraction (external, conceptual, internal). Tiers are deployment.
  • Calling the browser and the server two tiers of a web application. A web application with server side logic and a separate database is three tier; the browser is the presentation tier.
  • Saying three tier is always better. For a single user embedded tool it is pure overhead.
  • Forgetting the security argument. The strongest case for three tier is that the client never holds database credentials.

Exam and interview questions

  1. Draw and explain one tier, two tier and three tier architecture.
  2. Differentiate three tier architecture from the three level architecture.
  3. Give two advantages and two disadvantages of two tier architecture.
  4. Why does three tier scale better than two tier? Answer in terms of connections.
  5. In which architecture does the client hold database credentials, and why is that a problem?

Practice

  1. Classify each as one, two or three tier: a mobile banking app, a spreadsheet with an embedded database, a hospital desktop program connecting straight to a server, a public web store.
  2. A two tier system has 500 clients each holding one connection. Explain what three tier changes, with numbers.
  3. List three things that must be made redundant before an application server stops being a single point of failure.

Conclusion

One tier keeps everything on one machine, two tier puts logic on the client and exposes the database to it, and three tier inserts an application server that holds the logic, pools the connections and lets the database hide behind it.

Written by Lorens Mishra

Default administrator account created by the installer.

Continue reading

All DBMS notes →

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.