Load balancer - Think of it as a set of AWS-managed servers across Availability Zones (AZs) that front-end your instances and balance traffic to them.
Autoscaling group - If you mean EC2 autoscaling, this helps you create a set of instances across AZs that will increase or decrease in number in response to conditions you define, e.g. CPU load on the running instances, or number of messages in an SQS queue the instances are reading from.
Note the SQS example I mentioned - you may have autoscaling without load balancing for a "worker tier". Or, often the two work together where a load balancer targets the instances in an autoscale group, balancing traffic to them.
From an AWS services point of view:
Load Balancing as it sounds is related to balancing out the traffic to multiple targets to achieve stability. It is also referred to as Elastic Load balancing. Elastic Load Balancing (ELB) automatically distributes incoming application traffic across multiple targets and virtual appliances in one or more Availability Zones (AZs).
vs ASG or an auto-scaling group enables you to use Amazon EC2 Auto Scaling features such as health check replacements and scaling policies. The size of your auto scaling group is maintained according to a pre-defined number of instances, which you configure as the required capacity. You can use manual or automatic sizing to resize groups according to application requirements.
Load Balancer distributes the application traffic across multiple targets such as EC2 instances, IP addresses and containers. If I have two running instances and N number of members are requesting for access their data. Then load balancer will distribute those N requests evenly between two running instances. Load balancer decreases the load on the individual instance and increases the overall performance of the application. There are few load balancer choices on AWS:
- Application Load Balancer: Operates at layer 7. Targets IP instances, Lambda, containers. Supported protocols are HTTP, HTTPS, gRPC
- Network Load balancer: Operates at layer 4. Targets IP, instances, ALB, containers. Supported protocols are TCP, UDP, TLS
- Gateway Load Balancer: Pass through load balancer that operates as layer 3 gateway and layer 4 load balancer. Targets IP, instances. Supported protocols are IP.
- Classic Load Balancer: Operates at layer 4/7. Targets EC2-Classic. Supported protocols are TCP, SSL/TLS, HTTP, HTTPS. Classic load balancer isn't actively developed.
- AWS Global Accelerator: Acts like a load balancer. Operates at TCP/UDP. Targets IP, ALB, NLB. Supported protocols are TCP, UDP
Autoscaling is used to automatically increase and decrease the number of instances based on the application requirement. It ensures that you have the correct number of instances available to handle the load for your application. For example, an Auto Scaling group has a minimum size of 1 instance, a desired capacity of 2 instances, and a maximum size of 4 instances. The scaling policies that you define adjust the number of instances, within your minimum and maximum number of instances, based on the criteria that you specify. The goal of an Auto Scaling Group is to:
- Scale out (add EC2 instances) to match an increased load
- scale in (remove EC2 instances) to match a decreased load
- Ensure we have a minimum and a maximum number of machines running
- Automatically register new instances to a load balancer
Thanks very much for all them who answered my query, i have got a better understanding now.
i have 1 instances and i am using application load balancerasked 8 days ago
Create ECS service using existing load balancer with existing target groupasked 8 months ago
Load balancer page in AWS console doesn't loadAccepted Answerasked 6 months ago
Cannot select a target group with alb target type when creating an application load balancerAccepted Answerasked 3 months ago
What is the main differences between an load balancer and a autoscaling groupAccepted Answerasked 2 months ago
What is main difference between DDoS testing and Stress/load test?Accepted Answerasked 2 months ago
Load Balancer HTTP 413 Errorasked 5 months ago
ECS fails to remove a task from the load balancer target group?asked 5 months ago
My Network Load Balancer is not enforcing the target Security groupasked 3 years ago
What are the key differences between IAM roles and IAM policies?Accepted Answerasked a month ago