简体   繁体   中英

Auto-scaling load balanced EC2 instances by example

I am reading up on AWS Auto Scaling Groups and trying to understand (from a network-perspective) how the following resources all fit together:

  • Auto Scaling Group (ASG)
  • Application Load Balancer (ALB)
  • Individual EC2 instances sitting behind the ALB
  • ALB Listeners
  • ALB Target Groups
  • Security Group(s) enforcing which IPs/ports are allowed access to the EC2 instances

I understand what each of these does in theory, but in practice, I'm having trouble seeing the forest through the trees with how they all snap together. For example: do I configure the EC2 instances to be members of the Security Group? Or do I do that at the balancer-level? If I attach the ALB to the Auto Scaling Group, then why would I need to do any additional configuration with an ALB Target Group? When it comes to routing, do I route port 80 traffic to the ALB or the Auto Scale Group?

I know these are lots of small questions, so the main question here is: how do all of these snap together to provide a load balanced web server hosted on EC2 instances? Ultimately I need to configure all of this inside a CloudFormation template, but a diagram or explanation to help me configure everything manually is probably the best place for me to start. Thanks for any help!

do I configure the EC2 instances to be members of the Security Group? Or do I do that at the balancer-level?

The EC2 instances should be a member of one security group. The Load Balancer should be a member of another security group. The Load Balancer's security group should allow incoming traffic from the Internet. The EC2 instances should allow incoming traffic from the load balancer.

If I attach the ALB to the Auto Scaling Group, then why would I need to do any additional configuration with an ALB Target Group?

If you are using an auto-scaling group to create the instances, then you don't have to do any manual updates to the target group, the auto-scaling group will handle those updates for you.

When it comes to routing, do I route port 80 traffic to the ALB or the Auto Scale Group?

An Auto-scaling group is not a resource that exists in your network. It is a construct within AWS that just creates/removes EC2 servers for you based on metrics. The traffic goes to the load balancer, and the load balancer sends it to the EC2 instances in the target group.

I know these are lots of small questions, so the main question here is: how do all of these snap together to provide a load balanced web server hosted on EC2 instances? Ultimately I need to configure all of this inside a CloudFormation template, but a diagram or explanation to help me configure everything manually is probably the best place for me to start.

It's a bit much to ask somebody on here to spend their free time creating a diagram for you. I suggest looking at the AWS reference WordPress implementations which they tend to use for providing reference implementations of auto-scaled web server environments.

See the "WordPress scalable and durable" CloudFormation template example here .

See the AWS WordPress Reference Architecture project here , which includes a diagram.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM