Crafting a Scalable Three-Tier Architecture Demonstrating Blue-Green Deployment

Create a VPC We start by creating a VPC, Subnets, Internet Gateway and Route Tables. Below is how I allocated Ip Addresses to the VPC and each subnet. VPC 10.0.0.0/16 10.0.1.0/24 - public subnet1 10.0.2.0/24 - public subnet2 10.0.3.0/24 - private subnet1 10.0.4.0/24 - private subnet2 Create a Bastion Server Create a Bastion that can only be accessed via SSH from your device IP Address and launch it. This highly improves security of your architecture. Create the Database Security Group Create the security group from the DB port 3306 to both the public subnets then create another rule for SSH only from the Bastion server we earlier created. This allows SSH connection only from the Bastion server improving security of the DB server. Create a Database We start by creating a subnet group with the two private subnets we earlier created. Then we create an SQL database placing it in the subnet group we created. We created an extra private subnet just to use it to create a subnet group but for this project we only need one. Create a Control Server We will use the control server to test the connection to the database before we deploy the image. We will install php, php-mysqli and mysql-server on the control server. Establish Connection to the SQL Database through SQL Workbench We will now establish a connection to the database through the Bastion host we created. We will use MySQL Workbench to establish this connection. Test the database by add users and marking their attendance I added three users under the AWS SAA track and I was able to check their attendance. Generating the report is proof that the application is communicating with the database. Create an Image (AMI) of the Control Server We create an image of the control server. At this point we can get rid of the control server since we will only make use of the it's AMI. Create a launch template from the AMI We need a launch template since we can specify the launch configurations like security groups before we launch the instances from the image. Create a Target Groups This will allow us to route traffic to the instances we will create based on our rules. We will then edit the listener port, port 80 and allow both the two target groups to use the same port. Create an Autoscaling Group We will create the autoscaling group and attached then to the target groups we created. While creating the autoscaling group, we will specify the desired capacity as 3, minimum capacity as 2 and maximum capacity as 5. The instances should be created as shown below. To access the machines created, you will use the DNS of the load balancers. As shown with the DNS address below. We can also see that the records we took before creating the launch templates are also present. Create CloudWatch Alarms This will inform the instances when to add or delete using specified parameters. We will create two EC2 alarms by Autoscaling. We will use CPU Utilization as the preferred metrics from both. For high utilization the threshold will be 75% and for low the threshold will be 25%. We will enable dynamic scaling and enable simple scaling. This will use the threshold we defined above to add or remove instances. Demonstrate Blue-Green Deployment We can do this under load balancers. We edit listeners traffic flow in different targets. For instance, we are doing an update on Target-1, we will send all the traffic on target-2 and once we are done with the update we can send traffic to target-1. The now updated site. SNS Notification (Optional) You can also configure SNS notification to alert you on any threshold you go past. This will help during cost optimization since you will be able to monitor your cost. Conclusion Building a three-tier architecture with blue-green deployment in mind enhances scalability and security while minimizing downtime. This approach streamlines updates, ensuring a seamless user experience and effective use of resources.

May 3, 2025 - 01:00
 0
Crafting a Scalable Three-Tier Architecture Demonstrating Blue-Green Deployment

Create a VPC
We start by creating a VPC, Subnets, Internet Gateway and Route Tables.
Below is how I allocated Ip Addresses to the VPC and each subnet.

VPC 10.0.0.0/16
10.0.1.0/24 - public subnet1
10.0.2.0/24 - public subnet2
10.0.3.0/24 - private subnet1
10.0.4.0/24 - private subnet2

Create a Bastion Server

Image description

Create a Bastion that can only be accessed via SSH from your device IP Address and launch it. This highly improves security of your architecture.

Image description

Create the Database Security Group

Image description

Create the security group from the DB port 3306 to both the public subnets then create another rule for SSH only from the Bastion server we earlier created. This allows SSH connection only from the Bastion server improving security of the DB server.

Create a Database

Image description

We start by creating a subnet group with the two private subnets we earlier created. Then we create an SQL database placing it in the subnet group we created.

  • We created an extra private subnet just to use it to create a subnet group but for this project we only need one.

Image description

Create a Control Server
We will use the control server to test the connection to the database before we deploy the image.
We will install php, php-mysqli and mysql-server on the control server.

Image description

Establish Connection to the SQL Database through SQL Workbench
We will now establish a connection to the database through the Bastion host we created. We will use MySQL Workbench to establish this connection.

Image description

Test the database by add users and marking their attendance
I added three users under the AWS SAA track and I was able to check their attendance.
Generating the report is proof that the application is communicating with the database.

Image description

Create an Image (AMI) of the Control Server
We create an image of the control server. At this point we can get rid of the control server since we will only make use of the it's AMI.

Image description

Create a launch template from the AMI
We need a launch template since we can specify the launch configurations like security groups before we launch the instances from the image.

Image description

Create a Target Groups
This will allow us to route traffic to the instances we will create based on our rules.
We will then edit the listener port, port 80 and allow both the two target groups to use the same port.

Image description

Create an Autoscaling Group
We will create the autoscaling group and attached then to the target groups we created.

Image description

While creating the autoscaling group, we will specify the desired capacity as 3, minimum capacity as 2 and maximum capacity as 5.

The instances should be created as shown below.

Image description

  • To access the machines created, you will use the DNS of the load balancers. As shown with the DNS address below. We can also see that the records we took before creating the launch templates are also present.

Image description

Create CloudWatch Alarms
This will inform the instances when to add or delete using specified parameters.
We will create two EC2 alarms by Autoscaling. We will use CPU Utilization as the preferred metrics from both. For high utilization the threshold will be 75% and for low the threshold will be 25%.

Image description

We will enable dynamic scaling and enable simple scaling.
This will use the threshold we defined above to add or remove instances.

Image description

Demonstrate Blue-Green Deployment
We can do this under load balancers. We edit listeners traffic flow in different targets.

Image description

For instance, we are doing an update on Target-1, we will send all the traffic on target-2 and once we are done with the update we can send traffic to target-1. The now updated site.

SNS Notification (Optional)
You can also configure SNS notification to alert you on any threshold you go past. This will help during cost optimization since you will be able to monitor your cost.

Image description

Conclusion
Building a three-tier architecture with blue-green deployment in mind enhances scalability and security while minimizing downtime. This approach streamlines updates, ensuring a seamless user experience and effective use of resources.