Implementation of Auto Scaling Group with Load Balancer can ensure the reliability of system. This implementation will target to auto scale the production server of Memzo with Staging Database on some other domain/sub-domain.
🛤 Steps
Memzo Instance AMI Creation
Test/Staging DB Setup
Launch Instance and Change DB config
Ensure if DB is functioning correctly using Dashboard
Create New AMI for Launch
Configured Launch Template for ASG (with custom user data)
Accessing using Domain Name and testing ASG Activities
❓ Difficulties Identified
1. When instance is added by ASG, Apache httpd service is stopped by default so need to configured launch template again to add User Data (Startup Script) when instance is being launched.
Ref :
instance Config -> Advance options -> user data
2. Application load balancer doesn't support Elastic IP. So tried with Network Load Balancer but It created a loop of https request redirections.
First solution is to use application load balancer -
Ref :
3. If there are crons running on server then Auto Scaling can lead to a state of Clashing Crons that can create challenges.
First solution is to Keep crons on other Server.
Another solution is to Allow only first instance of ASg to run crons.
Ref: https://serverfault.com/questions/727466/running-crontab-on-aws-auto-scaling-group
4. If Server is Using EBS volumes then ASG will replicate the EBS volumes for each instance and will clear all storage when the instance is terminated. To attach an EBS Volume to the instance is tricky in Auto Scaling Group.
Solution - Decoupling Compute from Storage. Ref : https://portworx.com/wp-content/uploads/2017/05/asg-slides.pdf
Another solution is to keep only one EBS volume and attach the same volume to instance while the instance is launching using the Advanced user-data in Launch Template configurations.
Ex:
Keep only one volume with enough required storage.
Also, check availability zone of EBS volume. As per the AWS policy volume available in speific zone can be atttached to multiple instances of same zone only.
Launch Template
Use above AMI image in Launch template and keep desired instance type (t2.small in our case), security group, etc.
Dont add any EBS volume in launch template. We’ll attach it using advance user-data of instance.