THREE-TIER ARCHITECTURE OVERVIEW
The three-tier architecture is a commonly used approach for implementing multi-tier applications. It involves a web server that hosts all of the static contents such as HTML, CSS, JavaScript, and images. The business logic layer is built using Lambda functions that are fronted by API Gateway APIs. Finally, the database layer is used for data storage.
The following illustration shows an example of a generic three-tier application in the AWS cloud.
Each of these layers does a specific task and can be managed independently of each other. This is a shift from the monolithic way of building an application where the frontend, the backend and the database are both sitting in one place and a failure of a single component can affect the performance and availability of the whole application.
OUR ARCHITECTURE — DEEP DIVE
High Availability: This is the ability of a system to operate continuously without failure for a designated period. If a natural disaster such as an earthquake or flood ever occurred and affected a data centre hosting our application, our application will not be available. With AWS, we can design our infrastructure to be by hosting it in another Availability Zone.
Fault-Tolerance: We need our infra to scale vertically by adding or removing instances depending on the traffic volume. We achieve this by using an AutoScaling group and it also helps by cutting costs since instances are shut down when they are not in use.
Modularity: With modularity, teams can focus on different tiers of the application and changes made as quickly as possible. Also, modularization helps us recover quickly from an unexpected disaster by focusing solely on the faulty part.
Scalability: Each tier of the architecture can scale horizontally to support the traffic and request demand coming to it. This can easily be done by adding more EC2 instances to each tier and load balancing across them.
Security: This is an integral part of a well-architected framework to ensure that our infrastructure is protected from attacks by hackers. We want to avoid exposing our interactions within the application over the internet. The backend and the database tier will be in the private subnet because we do not want to expose them over the internet. We will set up the Bastion host for remote SSH and a NAT gateway for our private subnets to access the internet. The AWS security group helps limit access to instances.
Below is the CloudFormation template code that consists of a Virtual Private Cloud with Route Tables, Internet Gateway, Subnets (public and private), Security Groups, and AutoScaling Groups. There’s a script that installs and starts an Apache web server:
CONCLUSION
Developing a Three-Tier Web Application can be an incredibly complicated process that requires a lot of manual work in the Management Console. Nevertheless, it becomes easier and less prone to errors when you automate the entire process with Infrastructure as Code (IaC) tools such as Terraform or CloudFormation.