AWS 是否支持加权负载均衡?

Does AWS support weighted load balancing?

A​​WS 本身是否支持加权负载均衡?

据我所知,ELB 只支持循环负载均衡(没有任何可配置的权重)。不过,我还没有找到可靠的文档。


我能想到的最简单的就是在前面放一个Nginx之类的负载均衡器,例如:

upstream backend  {
  server backend1.example.com weight=1;
  server backend2.example.com weight=2;
  server backend3.example.com weight=4;
}

在这里,在七个请求中,一个将转到后端 1,两个将转到后端 2,四个将转到后端 4。

它会起作用,但这也意味着您必须为此设置一个带有 Nginx 的服务器。如果 AWS 直接支持加权负载平衡,那么设置起来会容易得多。

您可以使用 Route53 weight 直接路由到您的服务器或多个 ELB

如果您使用 A​​WS Route 53 作为 DNS 服务,您可以在 DNS 记录上配置权重年龄。

DNS weight-age refer 2.2

Amazon Route 53 support Weighted Round Robin. Weighted Round Robin allows you to assign weights to resource record sets in order to specify the frequency with which different responses are served. You may want to use this capability to do A/B testing, sending a small portion of traffic to a server on which you’ve made a software change. For instance, suppose you have two record sets associated with one DNS name—one with weight 3 and one with weight 1. In this case, 75% of the time Route 53 will return the record set with weight 3 and 25% of the time Route 53 will return the record set with weight 1. Weights can be any number between 0 and 255.

How Elastic Load Balancing Works 文档页面指出:

With a Classic Load Balancer, the load balancer node that receives the request selects a registered instance using the round robin routing algorithm for TCP listeners and the least outstanding requests routing algorithm for HTTP and HTTPS listeners.

With an Application Load Balancer, the load balancer node that receives the request evaluates the listener rules in priority order to determine which rule to apply, and then selects a target from the target group for the rule action using the round robin routing algorithm. Routing is performed independently for each target group, even when a target is registered with multiple target groups.

弹性负载均衡服务支持加权循环法(您在其中指定权重)。

您可以将 Amazon Route 53 与加权路由策略结合使用。来自 Choosing a Routing Policy 文档页面:

Use the weighted routing policy when you have multiple resources that perform the same function (for example, web servers that serve the same website) and you want Amazon Route 53 to route traffic to those resources in proportions that you specify (for example, one quarter to one server and three quarters to the other).

基于 AWS 新功能的更新

最初,您无法在 LoadBalancer 上进行加权路由。但是,最近发生了变化

如果您使用的是应用程序负载均衡器,则可以设置将使用加权策略的 ListenerRule。

步骤:

  1. 创建您的负载均衡器
  2. 将侦听器添加到您的负载均衡器
  3. 在您的侦听器上添加侦听器规则
  4. 添加一个策略,根据您需要的任何 IF 语句转发流量
  5. 您现在可以选择添加多个目标组,添加这些目标组并为每个目标组分配一个加权金额。

您可以在此处查看突出显示此内容的 AWS 博客 post:https://aws.amazon.com/blogs/aws/new-application-load-balancer-simplifies-deployment-with-weighted-target-groups/