DEV Community

Cover image for Three Tier Architecture. Overview and Each tier explained.
Barrington Hebert
Barrington Hebert

Posted on

Three Tier Architecture. Overview and Each tier explained.

      Three tier architecture is a pattern, or order of operations that pertains to the manner in which we go about building an application or program. Each tier will run on it's own infrastructure, and can be developed simultaneously. A three tier architecture design benefits our code organization, and scalability, as well as providing a way in which we can visualize the interaction between different systems that help bring our application to life. The three tier architecture system consists of the Presentation Tier, Application Tier, and the Data Tier. In terms of web development, These tiers are referred to as the web server, the application server, and the database server. Before we get into the depths of three tier architecture's it is important to understand their distinction from it's layers, in conjunction with a basic understanding of one and two-tier architectures.

Image description

      Imagine you want to construct a building. Before you construct the building, you must go speak with an engineer, and the engineer gives you a plan, he calls his plan the three tier architecture plan. So you take this three tier architecture plan of his then go and speak with your contractors who will do the physical labor of creating this building. You tell the contractors about the three tier architecture plan for constructing the building, and how it will allow them to simultaneously construct each floor... cough cough each layer cough... of this building all at once. Let us also imagine that it is the future so it is possible to do so. The contractors are broken up into groups who will each focus on constructing a particular floor of the building.

Image description
This building used 3-tier architecture planning

Like the construction of this building in this scenario, the three tier architecture plan works similarly in it's layers. The first floor is the presentation floor, and will be designed in a manner which is attractive and friendly towards customers. The second and third floor will work closely together, where the second floor is a business floor that will will gather, validate, and calculate customer data, and the third floor will be called a data access floor that re-organizes information from the second floor to a way that can be understood by the fourth floor. The fourth floor is a database floor where all the information we need to send back to the customers is stored. The way these floors communicate will be via an elevator that is called the business object elevator. Hopefully it is no surprise to you that each floor represents a different layer, and the three tier architecture encompasses the strategy and organization of how these floors cough layers will be built.

Image description
This building did not use 3-tier architecture

      One might ask, why not do all three things on the same floor? This is where one tier architecture comes into play. One tier architecture will contain all 3 layers within one application. All data and logic is stored on the same system, systems that use one tier application are things like mp3 players, or MS Paint. The similarity being that the experience for each client will always be the same. The web application is static, meaning it will not change, and everyone will experience the same output or end result of the product. Two tier architecture is divided into 2 sections, the first tier will be the client layer and the second will be the server layer. The two tier architecture applications are apps where the user is directly communicating with a server that holds data, Microsoft Access is a good example of a two tier architecture, where the client is directly communicating with a back end server. Once again, many of these applications are static, but may store some unique information that occasionally changes based on the user, yet the majority of the end result is mostly the same. As for the 3 tier architecture, it consists of a multitude of layers, which pertains to the majority of E-commerce websites like Amazon, and CMS (content management systems) sites, such as WordPress. Due to the fact these applications being more complex, the three tier architecture allows for a separation of concerns and allows more scalability and more efficient maintenance.

Client Tier

Image description

      The first tier is the client tier, which is developed within a presentation layer. This layer considers your front-end framework, or how your app to be displayed, which can be via laptop, mobile phone, or even a smart TV! It is called the client/presentation layer because this is the layer that your clients will interact with, and where the magic of your code will be presented, such as your web browser. On this layer, the client will see text boxes, and buttons, and will enter information and interact with your page via clicking on things and entering information. All of this information will later be handled by our second tier, which is called our application tier.

Application Tier

Image description

      The second tier is called the logic tier. It will consist of a business logic layer, and a data access layer. These layers consider the workflow, or the manner in which the first tier information will be handled from behind the scenes. This is where the heart of the application lies. It is considered the Application tier because this is where your front-end code will begin to handle the business logic of performing tasks based on the users interactions with your application. This tier will contain your JAVA , PHP, Python, or basic development tools and files. It may also come with a separate data access layer, which will use the information from the business logic layer and translate it into a way which will allow it to interact with a database, and will also relay information back to the presentation layer. This layer acts as a mediator between the business logic layer and database layer. Sometimes this tier, or a separate class, referred to as the business object, will use getters and setters to relay information to the database. If there is a business object that is focused on using getters and setters, it will be the primary tool in which information is passed between all layers. like an elevator!
elevator**

Database Tier //

      The third tier is called the data tier which essentially explains the necessity of a database layer that is dedicated to storing all information in a database. Your second tier will rely on information within the database in order to relay information back to the presentation layer. The database layer is where the data is stored, which will pertain to server operating systems such as Oracle and MYSQL. It is not user friendly and in many cases will mostly consists of information organized into tables. The first two tiers rely heavily on the information and data stored here.

Image description

      So this is essentially the 3 tier architecture. The first tier being where you enter information, the second tier being where this information is handled, and the third tier being where the data for the second and first tier is stored. As we can see there are many different forms of logic and software at play here. We can find HTML and css styling in presentation, javascript/php/python in the second tier, and SQL/Oracle in the third tier. Due to all these logics and different forms of code which will heavily rely on each other, many successful businesses will use the 3 tier architecture in order to layout a plan that results in faster development, improved scalability, reliability, and security. In web development we can see these tiers referred to as the web server, application server, and database server; yet the overall concept and theory is the same. With planning being the most important part within all forms of construction, software development can also be seen to have adopted these concepts; and apply them via three-tier applications. Hopefully this article has helped you further understand three-tier architecture. -Cheers

Top comments (0)