18

I guess this question could be entitiled, how do CDN's work at the DNS level but the real problem I have is that my company has datacenters in three continents and we have to have europe.example.com us.example.com and asia.example.com

CDN's typically send you to the local datacenter I imagine depending on your IP address. This must be a DNS thing where you have the DNS server in USA send you to a USA datacenter for the same example.com DNS lookup?

Am I wrong? If I am wrong about this, how would I do this effectively and if possible without central (non DNS) servers?

Joel Coel
  • 12,910
  • 13
  • 61
  • 99
Stewart Robinson
  • 1,145
  • 4
  • 12
  • 24

5 Answers5

15

The trouble with CDNs is that they don't direct you based on your own IP address - they direct you based on the IP address of your DNS server... That could be completely wrong. And do read Paul Vixie's ACM article, it's bang on the money.

Anyhow, if you've already got region.example.com set up and running, you could consider doing an HTTP redirect from example.com to the relevant webserver, based on the client's IP address.

That's pretty much what Google does, it's how I end up at google.co.uk having typed in google.com.

Do also ensure though that you provide a means for clients to get to the other variations. Clients don't like it when they're forced to a particular site, whether by mistakes in the Geo databases or simply because they actually need to see the site from another region.

Alnitak
  • 20,901
  • 3
  • 48
  • 81
7

Newer CDNs (Cloudflare, MaxCDN, fast.ly) use anycast for both DNS and actual content servers. This is somewhat better than trying to use the source IP of a DNS query and an ever changing mapping database.

In theory using anycast for both the DNS and content servers allows the network itself to find the "closest" servers to the client. In practice, this is mostly true, but some weird cases arise where people in Singapore will hit edge servers in California instead of Hong Kong due to the ever-changing peering relationships between ISPs.

Anycast is difficult to do well.

Older CDN like Akamai and Limelight generally use anycast to get you to the closest DNS server, but then take the guess-based-on-source-IP approach. This doesn't work as well in my experience, especially if a client is using DNS severs that aren't actually nearby in terms of network topology. However, a huge established CDN like Akamai has hundreds of content server locations, so returning a "close enough" answer results in a decent user experience. Obviously, having hundreds of sites is very expensive, which is why none of the all-anycast CDNs chose that route. Consequently, They also don't charge as much for mostly-equivalent service.

rmalayter
  • 3,744
  • 19
  • 27
1

There are a number of ways to handle this, but they all boil down to figuring out where an IP address is, and pointing it accordingly. For example, you might specify a range of IPs for North America and one for Europe. If the IP requesting the information (from DNS, your webserver, your content server, etc.) falls in the European range, then your European servers should get the requests.

Ben Doom
  • 684
  • 3
  • 6
  • Ben, what do you mean? Do you mean I have a DNS server in the US and one for instance in the UK. When I think about DNS I simply set my A record and I am done. How can I specify these DNS servers on a regional basis? – Stewart Robinson Nov 30 '09 at 18:47
  • I believe what he's referring to is something like views in bind. You could setup different views inside DNS that match based on the client's IP address, which can be roughly identified as belonging to a geographic region. There are many services available that you can pipe a request to an API and get a location from. Looking around briefly, you might try http://www.hostip.info/dl/index.html for a lower/no cost option. – Greeblesnort Nov 30 '09 at 21:23
  • just happened to run across this in my evening browsing: http://blogs.techrepublic.com.com/networking/?p=2279&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+techrepublic%2Fnetworking+(TechRepublic+Networking) – Greeblesnort Dec 01 '09 at 02:42
  • @Stewart -- no, you would not run one DNS server per region. Well, you could, but that would be for redundancy, as the DNS system itself is location-bline. @greeblesnort's answer is almost as good as his name. :-) – Ben Doom Dec 01 '09 at 23:33
0

You could setup a default main page at example.com. The first time someone visits they select which region they want to be directed to. This is the same way that www.ups.com works.

The user can select a check box to make this his/her default choice from that point on, thus storing the selection in a cookie.

This gives you to benefit of using DNS in the manner it was designed for according to Paul Vixie, while allowing your user to make the most accurate decsion on which data center they should be directed to.

Richard West
  • 2,968
  • 12
  • 42
  • 49
-1

If you have a website that's hosted in multiple regions then you don't need to do anything at the DNS level. You can use an API such as http://ipinfo.io to get the visitor's country, and then redirect them to the appropriate URL.

If we're not talking about a website, or any protocol that handles redirects, then there are a few options at the DNS level. You could do the same IP country lookup and then return a record that matches the region (geolocation based DNS), or you could have a map of the latency between different networks, and return a record that represents the lowest latency for the user (latency based DNS). Amazon's Route53 DNS service offer both.

Ben Dowling
  • 119
  • 3