2

I've read through the docs on AWS CloudFront and CloudFlare CDN, and both of them appear to require either ownership (to be the registrar) of a domain, or at least to have their DNS pointed to as the nameserver by the registrar which owns the domain.

This comes as a surprise to me for I had imagined that all I'd have to do is use an ALIAS and an IP to point to the CDN (like most servers). From what I know of a CDN, they're just servers which specialize in load balancing and caching.

What about the way CDNs function makes it so they require full control of a DNS and don't simply reveal an IP to be used as an ANAME item in the pre-existing DNS?

  • Probably because there is no standardized solution, and ANAME or ALIAS is a proprietary, hence local feature. By controlling your nameservers they guarantee to implement it in a way locally that it works. If you give control of your nameservers to another party, there is no guaratee. CNAME at apex (the problem for which ANAME/ALIAS workaround exists) is difficult: main question, should the resolution happen at query time or before, and then how it is refreshed? Note that a new standard with new records SVCB/HTTPSSVC (temporary names) is emerging and if fully standardized is a solution. – Patrick Mevzek Nov 14 '19 at 16:26
  • "and ANAME or ALIAS is a proprietary." Wow, I did not realize this. Never-the-less, IPs are standardized and seem like a good way to yield an entry point for a CDN. I read that CDNs typically have many IPs. Do IPs always resolve to one specific server, while names are more able to be localized? – Seph Reed Nov 14 '19 at 16:35
  • The problem is the "CNAME at apex". You can do "www.example.com CNAME some-cdn-host.example" once in your DNS and then the CDN can work. But you can NOT do "example.com CNAME some-cdn-host.example", due to the semantics of CNAME. For that case there is currently ANAME/ALIAS/whatever other proprietary local case to handle that, and maybe SVCB/HTTPSSVC in the future, but in short nothing standardized today. – Patrick Mevzek Nov 14 '19 at 17:20
1

You have some misconceptions about what a content delivery network (CDN) is:

  • Yes a CDN does specialize in caching
  • A CDN does not typically do any load balancing
  • A CDN maintains a network of "edge nodes" -- caching proxy servers distributed globally to be near users.

Here is a network diagram showing multiple web servers being used with a load balancer and a CDN:

To get this to work, a CDN plays tricks with DNS. Rather than just returning an IP address for the domain name, it returns different IP addresses to different users. It does so in such a way as to try to make sure each request from a user goes to the closest edge node.

The speed increase comes when a user requests a cached document from an edge node. Then:

  • The edge node is nearby and the network trip to request the document is reduced.
  • The edge node returns the document from cache which is often much faster than having the web servers generate the document.

To be able route different requests to different edge nodes, the CDN needs to be in control of DNS. Using an ANAME won't work because that would return the same IP address to every user.

Technically, the CDN is a step removed from DNS requests. And end user makes a DNS request to their ISP's DNS server which then makes a request to the authoritative DNS server for that domain. So when an end user gets an IP address to use, it is usually the one closest to their ISP's DNS server and not always the one closest to them. See this on ServerFault.

Here is an in-depth article that has quite a bit about different ways that CDNs work: https://www.sciencedirect.com/science/article/pii/S2352864817300731 See section 2.4 which goes into DNS based redirecting which is the style that I've described in this answer.

The article notes that CNAME DNS records can be used. However, CNAMEs have practical limitations. They can't be used for the bare domain name, only for subdomains. If you want to run your website without www, a CNAME is not possible.

| improve this answer | |
  • IP addresses can not be localized in the same way, correct? So even if there was a CDN with an IP that chose edge nodes based off the user, it would all pass through that original (poorly localized) server? – Seph Reed Nov 14 '19 at 16:41
  • Only for the initial request. Subsequent requests for the same document would be cached by the edge node and only involve the edge node. Edge nodes could also communicate with each other to pass around frequently requested documents rather than communicate with the centralized web server. – Stephen Ostermiller Nov 14 '19 at 16:43
  • IP addresses can be anycasted. All users can be given 192.0.2.42 but yet it will have the related traffic going in different locations based on the source. – Patrick Mevzek Nov 14 '19 at 17:21
  • @PatrickMevzek from what I've read, CloudFlare uses both anycast and DNS tricks. I focused on the DNS tricks because that is the reason they want to be the DNS host for your domain. – Stephen Ostermiller Nov 14 '19 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.