A Web application is an application that can be accessed through the internet using a web protocol, such as Hypertext Transfer Protocol (HTTP), by a client application such as a web browser. You must have interacted with a web application that inputs some data to process and output some result. For example, we all used online banking to transfer funds to different accounts, these type of services are sophisticated example of web applications.

Now let’s discuss various types of architectures used to implement these web applications.

2-tier Architecture or client-server architecture: In 2-tier architecture, web applications are divided in 2-tier namely client and server. A client is a machine that requests for a resource and server is a machine used to complete this requests by corresponding response.

Client-Server Architecture

In client-server architecture, client machine is responsible for presentation logic, business logic and persistence logic. The presentation logic is the code used to listen requests from the end user, responds to particular request and present it. Business Logic is the actual code used to implement  the business rules of the system, and the persistence logic is the code that helps to retain actual application data.

For example, Suppose you  want to create software for bank employees that helps them to generate monthly statements then,  the data resides in database server and front-end application is actually implemented on client machine. Employees interact with the application by clicking buttons and drop-down options etc. to retrieve details from the server. But this approach has some drawbacks namely:

• Complexity increased as the presentation logic is combined with business logic and difficulty in modifying the presentation logic.

• Providing services for different types as different presentation logic is required by different clients. As presentation logic is coded in client machine,  the cost of developing a 2-tier application increases.

Due to above mentioned problems 3-tier architecture arrives to effectively tackle these hurdles.

3-tier Architecture or n-tier architecture: 3-tier architectures consists of three tiers namely client, middleware server, and back-end server or simply server. The client tier is responsible for presentation logic and for accessing middleware server, the middleware server is responsible for implementing business logic. The back-end server maintains business logic.

3-tier Architecture
3-tier Architecture

The client and middleware server applications are physically separate, i.e. they run in different processes, possibly on different machines. Communication between these two tiers is maintained through network calls. In the above figure, the logic tier and data tier are physically separate.

Advantages over 2-tier architecture: 

• Reuse of business logic with different types of clients.

• Availability and scalability of applications increases.

• Better management of resources.

3-tier reduces the time to create separate client programs (presentation logic) in different platforms.