在某些情况下,AWS ELB 不会将请求分发到 Auto Scaling 组 EC2 实例 [英] AWS ELB doesn't distribute requests to auto scaling group EC2 instances in some cases

查看:19
本文介绍了在某些情况下,AWS ELB 不会将请求分发到 Auto Scaling 组 EC2 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jmeter 对我的 AWS Auto Scaling 组进行性能测试.

I'm trying to do performance testing for my AWS auto scaling group using jmeter.

首先,我进行了放大/缩小测试.我将阈值设置为 70% cpu 利用率 2 个周期,每个周期为 2 分钟.ELB工作正常,在系统横向扩展后,请求被分发到Auto Scaling组中的所有EC2实例,尽管不相等.

Firstly, I did scale-in/out testing. I set the threshold to be 70% cpu utilization for 2 periods, each period is 2 minutes. The ELB works fine, and the requests was distributed to all EC2 instances in auto scaling group, in spite of un-equality, after the system scale-out.

接下来,我想测试两个实例的负载是否可以是一个实例的两倍.我固定了自动伸缩组的实例数,我将最小/最大/期望的实例数设置为2.当我从单个JMeter推送负载时,总是只有一个实例在工作,并且其cpu利用率几乎达到100%,但是另一个实例的 CPU 利用率仍然为零....如果我从包含多个从属的 JMeter 集群推送负载,则所有实例都会加载.

In next, I want to test whether the two instances' load can be twice of one instance's. I fixed the instance number of auto scaling group, I set the min/max/desired instance count to be 2. When I push load from single JMeter, there are always just only one instance works and its cpu utilization reach almost 100 percent, but the cpu utilization of the other instance is still zero.... If I push load from an JMeter cluster which contains several slaves, all instances take load.

有人说,可能是负载不够重,ELB认为只有一个实例可以处理,没有将请求分派给其他实例.我不这么认为,因为我只是从这个 JMeter 集群的一个从站推送负载,但是我增加了负载,只有一个实例处理请求.

Somebody said, maybe the load is not heavy enough, so the ELB considered that just one instance can handle it and didn't dispatch requests to other instance. I don't think so, because I push load from just one slave of this JMeter cluster, however I increase the load, just only one instance handle requests.

我发现了一个博客,上面说 ELB 在 HA 方面很棒,但在负载平衡方面不是很好.https://www.stackdriver.com/elb-affinity-problems但是,我不认为这种行为,只有一个实例处理请求,是正常的.

I found an blog which said ELB is great in HA but not load balancing. https://www.stackdriver.com/elb-affinity-problems But, I don't think the behavior, only one instance handle requests, is normal.

ELB 负载均衡机制到底是什么鬼?我糊涂了.

What the hell in the ELB load balance mechanism? I'm confused.

推荐答案

Elastic Load Balancing 机制

  • DNS 服务器使用 DNS 循环来确定特定可用区中的哪个负载均衡器节点将接收请求
  • 选定的负载均衡器检查粘性会话"cookie
  • 选定的负载均衡器将请求发送到负载最少的实例

更详细的:

可用区(不太可能)

默认情况下,负载均衡器节点将流量路由到同一可用区内的后端实例.为确保您的后端实例能够处理每个可用区中的请求负载,在每个可用区中拥有大致相等数量的实例非常重要.例如,如果您在可用区 us-east-1a 中有 10 个实例,在 us-east-1b 中有两个实例,则流量仍将在两个可用区之间平均分配.因此,us-east-1b 中的两个实例必须提供与 us-east-1a 中的十个实例相同数量的流量.

By default, the load balancer node routes traffic to back-end instances within the same Availability Zone. To ensure that your back-end instances are able to handle the request load in each Availability Zone, it is important to have approximately equivalent numbers of instances in each zone. For example, if you have ten instances in Availability Zone us-east-1a and two instances in us-east-1b, the traffic will still be equally distributed between the two Availability Zones. As a result, the two instances in us-east-1b will have to serve the same amount of traffic as the ten instances in us-east-1a.

会话(很可能是您的情况)

默认情况下,负载均衡器将每个请求独立地路由到负载最小的服务器实例.相比之下,粘性会话将用户的会话绑定到特定的服务器实例,以便在会话期间来自用户的所有请求都将发送到同一个服务器实例.

By default a load balancer routes each request independently to the server instance with the smallest load. By comparison, a sticky session binds a user's session to a specific server instance so that all requests coming from the user during the session will be sent to the same server instance.

当为应用程序启用粘性会话时,AWS Elastic Beanstalk 使用负载均衡器生成的 HTTP cookie.负载均衡器使用一个特殊的负载均衡器生成的 cookie 来跟踪每个请求的应用程序实例.当负载均衡器收到请求时,它首先检查请求中是否存在此 cookie.如果是,则将请求发送到 cookie 中指定的应用程序实例.如果没有cookie,负载均衡器会根据现有的负载均衡算法选择一个应用实例.一个 cookie 被插入到响应中,用于将来自同一用户的后续请求绑定到该应用程序实例.策略配置定义了 cookie 到期时间,它确定了每个 cookie 的有效期.

AWS Elastic Beanstalk uses load balancer-generated HTTP cookies when sticky sessions are enabled for an application. The load balancer uses a special load balancer–generated cookie to track the application instance for each request. When the load balancer receives a request, it first checks to see if this cookie is present in the request. If so, the request is sent to the application instance specified in the cookie. If there is no cookie, the load balancer chooses an application instance based on the existing load balancing algorithm. A cookie is inserted into the response for binding subsequent requests from the same user to that application instance. The policy configuration defines a cookie expiry, which establishes the duration of validity for each cookie.

路由算法(不太可能是你的情况)

负载均衡器节点使用leastconns 路由算法将请求发送到同一可用区内的健康实例.leastconns 路由算法有利于具有最少连接或未完成请求的后端实例.

Load balancer node sends the request to healthy instances within the same Availability Zone using the leastconns routing algorithm. The leastconns routing algorithm favors back-end instances with the fewest connections or outstanding requests.

来源:Elastic Load Balancing 术语和关键概念

希望有帮助.

这篇关于在某些情况下,AWS ELB 不会将请求分发到 Auto Scaling 组 EC2 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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