AWS EC2 Contd
- Consider the following application
- Every webserver has a limit on parallel or concurrent connections
- One way of solving this is increasing cpu and RAM (vertical scaling) and other way to solve this is increase number of servers (horizontal scaling)
- When you have predicatable loads, we can create, start and shutdown/terminate servers based on some time schedules. But in most of the cases the load on the server is unpredicatable.
- It will be good if we can automatically increase the servers and decrease the servers based on some metric and if you can do this this is called as elasticity.
- All the clouds support this option. In the case of AWS we can do this by AWS Auto Scaling Groups.
- To work with autoscaling groups:
- We need an AMI with application preinstalled.
- We need to create ec2 instances in different AZ in a region to make them highly available.
- We need to understand metrics.
Amazon Machine Images (AMI)
- AMI includes back of an EBS (Snapshot) and additional information called as metadata.
- Amazon MarketPlace:
- AMIs can be created from
- EC2 instance
- EBS Volume (Virtual Disk)
- Third party Tools like Packer Refer Here
- EC2 image builder
- AMI Image creation for Different environments
- In the above case, we should have an automated approach.
- In some corner cases, we can opt for manual approach.
- Every AMI has a unique id called as AMI id and the Same image will not have same id across regions.
- Create a ubuntu linux server
- Execute the following commands
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php
sudo systemctl restart apache2
- Ensure this Ec2 instance is running before the next session.