简体   繁体   English

AWS Application Load Balancer-重定向一小部分流量

[英]AWS Application Load Balancer - Redirect small part of the traffic

Is there a solution to redirect a small part of the traffic to a AWS Application Load Balancer? 是否有解决方案将一小部分流量重定向到AWS Application Load Balancer?

10 % -> ALB X 10%-> ALB X

90% -> ALB Y 90%-> ALB Y

(ALB or Target Group) (ALB或目标组)

Thank you for helping 感谢您的帮助

You could use Amazon Route 53 - Weighted Routing : 您可以使用Amazon Route 53-加权路由

Weighted routing lets you associate multiple resources with a single domain name (example.com) or subdomain name (acme.example.com) and choose how much traffic is routed to each resource . 加权路由使您可以将多个资源与单个域名(example.com)或子域名(acme.example.com)相关联,并选择将多少流量路由到每个资源 This can be useful for a variety of purposes, including load balancing and testing new versions of software . 这对于多种目的很有用,包括负载平衡和测试软件的新版本

I finally choose that good NGINX solution : 我最终选择了一个好的NGINX解决方案:

https://medium.freecodecamp.org/ab-testing-with-nginx-in-40-lines-of-code-d4f94397130a https://medium.freecodecamp.org/ab-testing-with-nginx-in-40-lines-of-code-d4f94397130a

Because it is very simple to implement, easier than the solution provided by the AWS Support, if it is too long, go to the conclusion: 因为它实施起来非常简单,比AWS Support提供的解决方案容易,所以如果时间太长,请得出以下结论:

It is my understanding that you would like to know if it is possible to redirect a small part of the traffic to an Application Load Balancer. 据我了解,您想知道是否可以将一小部分流量重定向到应用程序负载平衡器。 Example: 例:

10 % -> ALB X 10%-> ALB X

90% -> ALB Y 90%-> ALB Y

This is possible with route53 weighted routing policy 这可以通过route53加权路由策略实现

Weighted routing lets you associate multiple resources with a single domain name (example.com) or subdomain name (acme.example.com) and choose how much traffic is routed to each resource. 加权路由使您可以将多个资源与单个域名(example.com)或子域名(acme.example.com)关联,并选择将多少流量路由到每个资源。 This can be useful for a variety of purposes, including load balancing and testing new versions of software. 这对于多种目的很有用,包括负载平衡和测试软件的新版本。 To configure weighted routing, you create records that have the same name and type for each of your resources. 要配置加权路由,请为每个资源创建具有相同名称和类型的记录。 You assign each record a relative weight that corresponds with how much traffic you want to send to each resource. 您为每个记录分配一个相对权重,该权重与您要发送给每个资源的流量相对应。 Amazon Route 53 sends traffic to a resource based on the weight that you assign to the record as a proportion of the total weight for all records in the group: Amazon Route 53根据您分配给记录的权重将流量发送到资源,占该组中所有记录总权重的一部分:

For example, if you want to send a tiny portion of your traffic to one resource and the rest to another resource, you might specify weights of 1 and 255. The resource with a weight of 1 gets 1/256th of the traffic (1/1+255), and the other resource gets 255/256ths (255/1+255). 例如,如果您要将流量的一小部分发送到一个资源,将其余部分发送到另一资源,则可以将权重指定为1和255。权重为1的资源将获得流量的1/256(1 / 1 + 255),而其他资源则为255/256(255/1 + 255)。 You can gradually change the balance by changing the weights. 您可以通过更改权重逐渐更改余额。 If you want to stop sending traffic to a resource, you can change the weight for that record to 0. 如果要停止向资源发送流量,可以将该记录的权重更改为0。

Also I understand that from your example if you attempted to route 10% of our API traffic through a separate Load Balancer and saw sporadic bursts of traffic which were inconsistent with our weight (much higher than 10%). 我也从您的示例中了解到,如果您尝试通过单独的负载均衡器路由10%的API流量,并发现零星的流量爆发,这与我们的体重不一致(远高于10%)。

I am taking an example of 50:50 weights to explain regarding consistency of traffic. 我以50:50的权重为例来说明流量的一致性。

Weighted routing policies in Route 53 allow you to simulate load balancing by assigning a weight for each record associated with a domain name. Route 53中的加权路由策略允许您通过为与域名关联的每个记录分配权重来模拟负载平衡。

The way this works is that the Route 53 name servers will return the IP address of each record proportionately to the weight given to them. 这种工作方式是Route 53名称服务器将根据分配给它们的权重按比例返回每个记录的IP地址。

This means that if you give the 50 weight to one record and 50 weight to another record, for instance record A (Weight:50)and record B(Weight:50),and the name servers are queried for the hostname 100 times, the name servers will return the IP address assigned to record A 50 times, and the IP address assigned to record B 50 times. 这意味着如果您给一条记录赋予50权重而给另一条记录赋予50权重,例如记录A(Weight:50)和记录B(Weight:50),并且名称服务器被查询100次主机名,名称服务器将返回分配给记录A的IP地址50次,分配给记录B的IP地址50次。

This, however, does not mean that each DNS query will result in an consistent amount of requests reaching each endpoint. 但是,这并不意味着每个DNS查询都会导致到达每个端点的请求数量保持一致。

Please keep in mind that weighted DNS routing does not equal load balancing, and cannot guarantee that the requests coming to the weighted resource records will be exactly equal. 请记住,加权DNS路由不等于负载平衡,并且不能保证到达加权资源记录的请求将完全相等。 This is caused by multiple factors, including DNS caching on client DNS caching servers, If one client receives the IP address of record A, it will keep it in its local cache for the duration of the DNS record's TTL, which for your record is currently 60 seconds. 这是由多种因素引起的,包括在客户端DNS缓存服务器上进行DNS缓存。如果一个客户端收到记录A的IP地址,它将在DNS记录的TTL持续时间内将其保留在其本地缓存中,这是您的记录当前60秒 For that time, the client can create multiple requests, while for the same time a client that has received the IP address of record B, can send a single request. 那时,客户端可以创建多个请求,而同时收到记录B的IP地址的客户端可以发送单个请求。

In other words, while DNS weighted routing (or weighted round robin), does not provide true load balancing, and cannot be expected to result in exact match of weight to incoming traffic to endpoints. 换句话说,虽然DNS加权路由(或加权轮询)不能提供真正的负载平衡,并且不能期望导致权重与到达端点的传入流量完全匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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