3 Tier Architecture In AWS | Demo of 3-tier web app in AWS with VPC, ALB...
What is 3-tier architecture in AWS:
The display layer, the business logic layer, and the data storage layer are the three logical tiers that are divided up into the application in a three-tier design. A client-server application with a front end, a back end, and a database, like a web application, uses this design. Each of these tiers or layers can be handled independently of the others and performs a particular function. This is a departure from the monolithic approach of application development, in which the frontend, the backend, and the database are all housed in the same location.
AWS is a cloud computing platform that offers consumers a variety of cloud computing services. Click on this link to see a list of all AWS services and goods. In this post, we'll use the Elastic Compute Cloud (EC2), Auto Scaling Group, Virtual Private Cloud (VPC), Elastic Load Balancer (ELB), Security Groups, and Internet Gateway AWS services to plan and create a three-tier cloud infrastructure. Our infrastructure will be created to be fault resistant and highly available.
Advantages of 3-tier Architecture:
A. HA i.e. Highly Available:
Our application is located in a single place when using a conventional data center. Our application won't be accessible if there is an earthquake, flooding, or even a power outage in the area where it is housed. By hosting our application in many places known as availability zones on AWS, we can design our infrastructure to be highly available.
B. Modularity:
Having a three-tier design is essential for modularizing our application so that each component can be controlled separately from the others. Teams can concentrate on various application levels and make changes as rapidly as feasible because to modularity. Additionally, modularization speeds up recovery from an unplanned catastrophe by concentrating just on the problematic component.
C. Scalability:
To accommodate the traffic and request demand going to it, each tier of the architecture may scale horizontally. This is simply accomplished by increasing the number of EC2 instances in each tier and load distributing among them. We can easily scale the backend tier by adding more EC2 instances to it so that the burden may be dispersed, for example, assuming we have two EC2 instances running our backend application and each of the EC2 instances is working at 80% CPU utilization. When the load is lower, we can also automatically decrease the number of EC2 instances.
D. Secure:
We want to create a highly secure infrastructure that is shielded from snooping hackers. We want to keep any online exposure of our interactions with the application to a minimum. Simply put, this means that the application will use a private IP to communicate among itself. The infrastructure's presentation (frontend) tier will be located in a private VPC subnet (a subnet without any instances with public IP addresses assigned to it). The frontend is only accessible to users via the application load balancer. Because we don't want to expose the backend and database tier to the public internet, they will also be in the private subnet. We'll set up a NAT gateway and the Bastion host for remote SSH.
E. Fault Tolerant:
Our infrastructure must be able to react without difficulty to any unforeseen change in traffic or problem. This is typically accomplished by including a backup mechanism that will take into account any eventual increase in traffic. Therefore, we have an extra instance making it three instances working at roughly 35% each rather than two EC2 instances working at 50% each, ensuring that when one instance goes bad, the other instance will be running at 100% capacity until a new instance is brought up by our Auto Scaling Group. This is typically weighed against the expense of installing a redundant system.
Follow the link to create machine:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2023.html
Commands for php application server for each server
sudo dnf update -y
sudo dnf install -y httpd wget php-fpm php-mysqli php-json php php-devel
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl is-enabled httpd
sudo usermod -a -G apache ec2-user
exit
groups
curl http://localhost
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
sudo dnf install php-mbstring php-xml -y
sudo systemctl restart httpd
sudo systemctl restart php-fpm
cd /var/www/html
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1
rm phpMyAdmin-latest-all-languages.tar.gz
sudo systemctl is-enabled httpd
echo "PHP Server 1" >index.html do for php server1
echo "PHP Server 2" >index.html do for php server2
sudo systemctl is-enabled httpd
my-alb-902956905.ap-south-1.elb.amazonaws.com
after cd phpMyAdmin
mv config.sample.inc.php config.inc.php
vi config.inc.php
replace host with ALB DNS Name Entry
user data for ec2 instances
#!/bin/bash
yum update -y
yum update httpd -y
systemctl restart httpd
Application Server user data
#!/bin/bash
yum update -y
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
yum install -y apache-maven
yum install java-1.8.0-openjdk-devel.x86_64 -y
db-server
#!/bin/bash
yum update -y
yum install mysql
ssh-add -K dev-account.pem
ssh -A ec2-user@<dns-name>
ssh ec2-user@<ip-address-application-server>
Login to web-server OR jump server
from there login to php-app-server
install
sudo yum update -y
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl is-enabled httpd
curl http://localhost
sudo usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
sudo yum install php-mbstring php-xml -y
sudo systemctl restart httpd
sudo systemctl restart php-fpm
cd /var/www/html
echo "PHP Server 1" >index.html do for php server1
echo "PHP Server 2" >index.html do for php server2
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1
rm phpMyAdmin-latest-all-languages.tar.gz
Networking:
vpc
webserver, appserver, db server
subnets - public and private subnets
route tables
associations with subnects
Internet gateway for public subet
NAT gateway for private subnets can communicate to web internet to download patches
create route to Internet Gateway and NAT gateway
Create JUMP server -
craeating EC2 instances for web server hosting in public subnets, allow internet access,
new securty group as web-sg, allow ssh conectivity
Create PHP server -
creating EC2 instances for app server in private subnets , allow access only from web-sg
Installing PHP, Apache
Installing phpMyAdmin App
create & configue ALB
create RDS instances and associate db subnet ,as RDS instances
Configuer PHPmyAdmin with RDS
Try login to appserver via webserver
modify config file to connect to RDS endpoint
Confire Session Stickyness
access the web app server using the URL from web
it shall connect to DB server
Thanks
DataPundit Group
Visit DataPundit
Comments
Post a Comment