AWS Autoscaling
- In EC2 instances we run our applications, as of now the approache which we are following is
- take an OS based AMI and manually install the application
- As number of users start using this applications the resources will be exhausted, so we do horizontal scaling (i.e. increasing ec2 instances to share the workload)
- The problem with the above apporach is whenever ec2 instance is scaled, we need to install software in it.
- We need to figure out a way to create an AMI with application pre-installed
- Even if we have AMI with our application pre-installed, what can be done to give a new release.
- AWS has a way when a new version of AMI is released then
- To acheive this we need to create
- AMI’s
- Autoscaling Groups
- Launch Templates
- LoadBalancers
- Target groups
- Automate the AMI creation from ci/cd pipeline
Creating AMI
- Create an ubuntu 22.04 AMI based EC2 instance
t2.micro
and login in to the ec2 instance - Install apache, php and stress
sudo apt update # not necessary on redhat
sudo apt install apache2 -y # sudo dnf install htttpd -y
sudo apt install stress -y
sudo apt install php libapache2-mod-php php-mysql -y # sudo dnf install php -y
sudo -i
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
-
navigate to
http://<public-ip>/info.php
-
Exercise:
- Create the php info page on centos or redhat based linux instances Refer Here
- Restart the ec2 instance and check if the apache is running or not
- Understand what enabling the service in linux means
- Enable the service in redhat instance
- Restart the server and check apache should be running