Search code examples
amazon-web-servicesamazon-s3amazon-cloudfrontamazon-route53

Weighted round robin dns between 2 Cloudfront distributions


We are trying to use aws to do some a gradual deployment test with our javascript code, but it seems to fail us

we created 2 S3 buckets with CF distributions :

a.example.net -> aaa.cloudfront.net

b.example.net -> bbb.cloudfront.net

than we created a weighted round robin DNS entry in route53

test.example.net -> (cname) -> aaa.cloudfront.net (5)

test.example.net -> (cname) -> bbb.cloudfront.net (95)

in the S3 bucket we put a file with the CF corresponding domain name for each bucket :

http://test.example.net/dns-test/test.txt

What I am expecting is to get 95% of the time bbb and 5% of the time d3nrwpaeicu4xy. What we actually get is aaa 100% of the time :(

I opened a ticket to the route53 team to check if this is a problem with the dns configuration but they have shown me , and I have seen it myself that the dns queries split between the 2 buckets.

Hope this is clear enough.


Solution

  • Unfortunately what you are trying to do is not possible. CloudFront, or any HTTP server for that matter, only see's the host header of test.example.com. It has no idea how you got there, be it WRR DNS or hosts file, it only see's the host header. I'm not sure how you configured the same CNAME on two CloudFront distributions, it shouldn't be possible.

    For this to work, you would need to utilize two different services, for example, S3 and CloudFront. Create a bucket for test.example.net and a CloudFront distribution configured with test.example.net. Then you can WRR as both services will serve your content for test.example.net