跨不同 Elastic Beanstalk 应用程序的负载平衡 [英] Load balancing across different Elastic Beanstalk applications

查看:28
本文介绍了跨不同 Elastic Beanstalk 应用程序的负载平衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 AWS 环境中有一些负载平衡/自动扩展的 Elastic Beanstalk 应用程序.

In my AWS environment there are some load balanced / autoscaled Elastic Beanstalk applications.

我想在他们面前有一个负载均衡器,所以任何对 http://loadbalancer.com/app1 的请求 被路由到第一个 Elastic Beanstalk 应用程序,http://loadbalancer.com/app2 到第二个等等.

I would like to have a load balancer in front of them, so any request to http://loadbalancer.com/app1 is routed to the first Elastic Beanstalk app, http://loadbalancer.com/app2 to the second and so on.

我尝试使用不同的侦听器路由到不同的目标组来设置应用程序负载平衡器.不幸的是,我的解决方案并不理想,因为目标组绑定到一组固定的 EC2 实例,而我希望它们与按需创建或销毁实例的环境相关联

I tried to set up an application load balancer with different listeners routing to different target groups. Unfortunately my solution is not ideal, because the target groups are bound to a fixed set of EC2 instances, while I want them to be associated to an environment where instances are created or destroyed on demand

我还没有找到将应用程序负载均衡器的侦听器绑定到 Auto Scaling 组的方法.

I haven't still found a way of binding an application load balancer's listener to an auto scaling group.

有没有办法实现我想要的?

Is there a way of achieving what I want?

推荐答案

我刚刚按照本文中的说明完成了https://aws.amazon.com/blogs/devops/introducing-application-load-balancer-unlocking-and-optimizing-architectures/

I just managed to do it, following the instructions in this article https://aws.amazon.com/blogs/devops/introducing-application-load-balancer-unlocking-and-optimizing-architectures/

步骤:

1) 创建一个新的目标组

1) create a new target group

    aws elbv2 create-target-group --name <target_group_name> --protocol HTTP --port 80 --vpc-id <vpc_id> 

2) 将您的目标组绑定到与应用关联的自动缩放组

2) bind your target group to the autoscaling group associated to the app

    aws autoscaling attach-load-balancer-target-groups --auto-scaling-group-name <id_of_the_autoscaling_group> --target-group-arns "<new_target_group_arns>"

3) 在主应用程序负载均衡器中创建一个新规则,将所需路径路由到正确的应用程序(这可以通过 UI 完成).

3) create a new rule in the main application load balancer, that routes the desired path to the right application (this can be done through the UI).

这篇关于跨不同 Elastic Beanstalk 应用程序的负载平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆