Search code examples
amazon-web-serviceselastic-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?

10 % -> ALB X

90% -> ALB Y

(ALB or Target Group)

Thank you for helping


Solution

  • I finally choose that good NGINX solution :

    https://medium.freecodecamp.org/a-b-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:

    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

    90% -> ALB Y

    This is possible with route53 weighted routing policy

    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. 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:

    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). 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.

    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%).

    I am taking an example of 50:50 weights to explain regarding consistency of traffic.

    Weighted routing policies in Route 53 allow you to simulate load balancing by assigning a weight for each record associated with a domain name.

    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.

    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.

    This, however, does not mean that each DNS query will result in an consistent amount of requests reaching each endpoint.

    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. 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. 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.

    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.