AWS Three Tier Web
Architecture
A three-tier
architecture is a common and well-established way to design applications. It
separates the application into three logical tiers:
1. Presentation Tier
(Web Tier): This tier handles how users interact with the application. It
typically consists of a web server that delivers content (like HTML pages) to
the user's browser. In an AWS context, this tier might involve services like
EC2 instances running a web server like Apache or Nginx.
2. Application Tier
(Business Logic Tier): This tier handles the core application logic. It
processes user requests, interacts with the database, and performs any
necessary business logic. On AWS, this tier could involve EC2 instances running
your application code.
3. Data Tier (Database
Tier): This tier stores the application's data. In an AWS environment, this
tier is often implemented using Amazon RDS (Relational Database Service), which
offers managed database solutions like MySQL, PostgreSQL, Oracle, and Aurora.
Here are some of the
benefits of using a three-tier architecture on AWS:
Our web tier EC2
instances receive client traffic that is forwarded by a public-facing
Application Load Balancer in this architecture. React.js websites are served by
Nginx webservers operating on the web tier, which also routes our API calls to
the application tier's internal load balancer. The traffic is subsequently
forwarded to the Node.js application tier via the internal facing load
balancer. Our web tier receives data from the application tier after it has
been modified in an Aurora MySQL multi-AZ database. To keep this architecture
available, load balancing, health checks, and autoscaling groups are
established at each layer.
Implementation
First, Create S3
Bucket and put your application code to S3.
Second, We need to
create a VPC, attach an Internet Gateway to it, and we will need six subnets
across two availability zones. That means three subnets will be in one
availability zone, and three subnets will be in another zone. Each subnet in
one availability zone will correspond to one layer of our three-tier
architecture. Create each of the 6 subnets by specifying the VPC we created
earlier and then choose a name, availability zone, and appropriate CIDR range
for each of the subnets.
Example:
Public-Web-Subnet-AZ-1, Private-App-Subnet-AZ-1, Private-DB-Subnet-AZ-1.
Third, create Security
Groups for your EC2 instances, load balancers, and database, with proper
inbound and outbound rules.
After that, create
an RDS Database by using multi-availability Zone deployment, which helps for
greater availability.
Next, create an EC2 instance
in your app-tier Subnet (Private), then connect to instances, download the MSQL
and configure the database, and download Node to run the backend application,
then copy the Backend code (from App Directory) to instance from S3 Bucket.
Next, create an EC2
instance in your web-tier subnet (public), then connect to instances, download
the required packages to run your Frontend Application, and copy the Frontend
code (from web directory) to instance from S3 Bucket.
Create 2 target
groups and deploy the 2 application load balancers (internal and external) and
select proper security groups to deploy the load balancer.
Create Launch Template
for both web instance and application instances and use this template to enable
autoscaling for web-tier and app-tier.
Now use public IP
from the web-instance and paste it in your web browser. You can see the
Application is getting served.
Finally, we
successfully created a three-tier web architecture which is Scalable, Highly
Available, Fault-Tolerant and Secure.