We have noticed a trend of more and more users wanting to use BunnyCDN for full website caching on the root domain. We have, for multiple reasons, been advising users against this and in this post I want to highlight one of them, the ANAME record.
What is an ANAME record?
So first, what is an ANAME record? To put it simply, an ANAME record is a mix of a CNAME and A type DNS records. It is not an actual DNS record type at all and could be better described as a virtual one. It works by resolving the linked hostname on the DNS server itself, and then caching and storing the IP of the result and returning that as an A record to the user.
An ANAME is mainly used for root domains only because DNS does not allow a CNAME record to be set for the root domain and ANAME works around that by providing a virtual CNAME.
How does this affect a CDN?
It all sounds great, but unfortunately there's a catch. In most cases, BunnyCDN routes users by looking at the IP of the querying DNS client that requested a DNS resolution for your CDN domain. Based on that, we do a GeoIP lookup and determine the location of the user. Since most users use default nameservers provided by their ISP, this is generally very accurate and in other cases such as Google DNS, their service even forwards the actual user's IP to make this even more accurate. However, in case of an ANAME the situation is a bit different.
Since an ANAME record is resolved by your domain provider and returned as an A record, our servers know nothing about the actual user connecting to BunnyCDN. It is actually the DNS service for your own domain that will hit our DNS server instead and in our eyes, this will be the user. This means our system will not get the actual location of your end user, but the DNS server for your domain, which can in many cases result in reduced performance due to poor routing on their side or simply a smaller network.
BunnyCDN operates a large global network of 35 PoPs and growing, but when using an ANAME you will effectively always be limited to the number of PoPs and network quality provided by your domain's DNS provider. If you are from India for example and your DNS service only has a nameserver in Singapore, BunnyCDN will simply end up routing you to Singapore instead of our Bangalore PoP and effectively routing your users thousands of kilometers away.
Should I be using ANAME?
Now that we know how big of an effect an ANAME can have on CDN routing, the question is, should I be usig ANAME? The answer is simple, if you really need to use a root domain, then an ANAME record is still the best choice. However, we strongly suggest making sure to match that with a very good DNS service provider that won't result in performance issues on your side.
If using a root domain itself is not an absolute requirement, we strongly suggest using a simple subdomain such as www instead. This removes the need to use ANAME records and guarantees good routing performance even if your DNS system only has a single PoP.