DNS, the orginal CDN

by Craig Mayhew on Sun 14th May 2017 under General/Techie

The Domain Name System has been around since the 1980s, and often doesn't get credit for how abundent and efficient it is. Most people know it as a way to translate website address such as craig.mayhew.io into an ip address so that your browser knows where to request a website from but what about it's little known uses?

How about the author of desktop software that needs to periodically check to see if updates are available. One could write code into the software to check a URL via HTTP, perhaps a JSON request that returns {latest:"1.7.3"}, perhaps over HTTPS because this is now the norm. If your software is popular, you could be making thousands or even millions of requests each day. This small API you are now serving will ofcourse need code of it's own, perhaps it's on a node server, or php server, or perhaps it's serverless and running on something like AWS Lambda. All this for a simple request to get a short string of numbers? What if I told you there was a service for this already, that has millions of server instances and multiple layers of caching to allow near zero cost distribution?

This problem could be solved by checking a single DNS entry. You don't even need to delve into TXT records, a simple A record would do the trick. We could simply have made a DNS lookup to version.oursoftware.tld. With a TTL of 7200 and a value of, an office with 500 installations of your software probably wouldn't make more than a few DNS lookups to your DNS service provider each day. The DNS server in their office will instead take the brunt of that by caching the answer at no cost. You have even done them a favour by saving them bandwidth. A DNS request/response is on the order of ~100 bytes, the HTTP requests could be anywhere from the same to 10x that depending on the use of HTTPS and which headers are used. So you've just turned 500KB of traffic into ~ 200 bytes. Good job! I know that doesn't seem like much by itself, but across millions of users it will really start to add up. If that business is using the same DNS service provider as hundreds of other offices, all of those businesses will still only be hitting our DNS service with ~12 DNS lookups each day (thanks to our 7200 second cache setting!). DNS scales, and people forget to use it for what it's good at. Distributing high read key:value pairs to billions of devices at near zero cost.

That ofcourse was just with IPv4 and an A record, you could send 4x the information (32 hexadecimal characters) using AAAA IPv6 records or even 64x using TXT records. There is, unfortunately, one limitation which prevents this technique in the world of browser based apps. You can't retrieve a DNS lookup. The browser abstracts this away and doesn't let you access the record values. So while there is a free, distributed, highly fault tolerant worlwide CDN that has been around for 30 years, there is no way to harness it for the majority of modern software. Wouldn't it be nice if browsers supported using DNS in this way.




Latest Blog Posts