2 and 3 Tier Architecture
A tier (not to be confused with layer) refers to the physical separation of an application. On the other hand, a layer refers to the logical separation of an application. Essentially, a tier is a physical separation of a layer. The 2 and 3 tier architectures are very common in software development. In this tutorial, we will be describing how this software architecture work, their advantages and disadvantages.
2 Tier Architecture
A 2 tier architecture refers to a software architecture in which a presentation layer runs on a client and a data layer is available on a server. Separating these two components into two different physical locations results in a two-tier architecture, as opposed to a single-tier architecture. The application on the client-side establishes a connection with the server in order to communicate with the data layer. The server-side is responsible for providing query processing and transaction management functionalities. On the client-side, the user interface and application programs are run. The 2 tier architecture has two tiers which are:
- Client tier that represents the clients.
- Data tier that holds the database server.
The diagram below shows a simple representation of a 2 tier architecture.
The 2 tier architecture has the following advantages:
- Applications can be easily developed and deployed due to simplicity.
- The database server and application logic is physically close, which offers higher performance, provided the users are manageable.
On the other hand, the 2 tier architecture disadvantages are:
- The performance of the application is degraded with increasing users. When simultaneous client requests are made, application performance degrades rapidly due to the fact that clients necessitate separate connections and increased CPU memory.
- Since the client holds most of the application logic, difficulties often arise in controlling software versions and distributing new versions.
- It’s often difficult to implement reliable security since users need to have login information for every data server.
3 Tier Architecture
A 3 tier architecture refers to a software architecture in which the user presentation interface, the business logic and the data storage server are developed and maintained as independent modules on separate hardware platforms. The client does not directly communicate with the database server. Instead, the client interacts with an application server which further communicates with the data tier which contains the database server that is used for query processing and transaction management. The business tier serves as a medium for the exchange for partially processed data between the database server and the client. A three-tier architecture often allows any one of the three tiers to be upgraded or replaced independently. The three tiers of this software architecture are:
- Presentation tier which represents the clients.
- Business tier which acts as an intermediary for partially processed data.
- Data tier which holds the database server.
The diagram below shows a simple representation of a 3 tier architecture.
The 3 tier architecture has the following advantages:
- It can scale without degraded performance since no separate connections from each client are not required.
- There is improved data integrity because data corruption from client applications can be eliminated by passing the data in the business tier for validation.
- It’s often easier to implement improved security since client applications don’t have direct database access.
- It’s possible to scale or change the implementation of a tier on its own without affecting other tiers of the system.
On the other hand, 3 tier architecture disadvantages are:
- There is increased complexity of implementation as the communication points are increased (presentation tier to business tier to the data tier, instead of direct client tier to data tier communication).
The 2 and 3 tier architectures are very common in software development. Both are advantageous and disadvantageous in various ways. However, the 3 tier architecture is generally regarded to be better than the 2 tier architecture.