EC2 - Load Balancing and Auto scaling
Load balancing and Auto scaling
Let's suppose we have deployed our web application to the EC2 instance. And all of the sudden, our app. got viral and previously 10k daily users became 1 million. So we want our infrastructure to use less resources when there is little or no user, more when there is high load or spike, it somehow must adjust itself in a way to withstand to this load. This is when auto scaling comes into play.
There are 3 types of load balancer in AWS:
- Application load balancer (operates at Application layer (L7) http, https etc.)
- Network load balancer (operates at IP layer (L4) - TCP, TLS, UDP etc.)
- Gateway load balancer (uses Geneva protocol, balances firewalls,IDS/IPS, operates at layer 3 )
Auto scaling - allows you to automatically and terminate EC2, ECS, EKS instances based on your needs. It maintains availability allows you to scale easily. We need to define our EC2 template, so each time when auto scaler needs to create new EC2 instance, it will use that. And there is one more thing I want to add on top of that, auto scaler needs some information when to create, when to terminate instances. Based on the CloudWatch data and auto scaling policy we define, it will scale the system.
Types of Auto scaling:
Manual - make changes to AutoScaler manually
Dynamic - automatically scales based on demand (request size, CPU usage etc.)
Predictive - uses Machine learning to predict
Scheduled - scales based on schedule (date/time)
Let's create auto scaler and connect it to the elastic load balancer
- First let's create own security group which will be very handy later on
- Add allow 80 and 22 ports to inbound rules.
- Add the script we used to create simple webpage in previous tutorial (https://www.blogger.com/u/1/blog/post/edit/6922501496740215722/8300358555009620696)
Comments
Post a Comment