문제

I'm using a System.Net.HttpWebRequest to hit an API application hosted within AWS behind a load-balancer. The LB has 6 instances, 3 in 2 different AZs. As a result, the DNS entry for the LB has 2 IP Addresses (1 for each AZ).

When I run my C# app, the web requests appear to be balanced perfectly between 3 servers within a single AZ. It's not hitting the 2nd AZ.

It seems to me that the WebRequest object is only ever hitting the 1st IP that is bound to the LB DNS entry, which is why traffic is balanced, but only in a single AZ.

Does that make sense? How do I get the WebRequest to target other IPs bounds to a DNS entry?

도움이 되었습니까?

해결책

HttpWebRequest always uses the first IP address in the list. Route53 returns the IP addresses from a single loadbalancer in a random order which help balance the load across the AZs.

다른 팁

When C# does a DNS lookup (via .NET) it'll cache that result. This means that it will continue using whatever IP it gets back first.

Take a look at How do I clear System.Net client DNS cache? -- this might steer you in the right direction.

I think you have run into one of the weaknesses of the the AWS ELB. All requests from a single IP will get routed to one AZ. This makes the elb problematic for web services that have alot of traffic but only from a small ip subset.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top