The Tortoise, the Hare, and the Duck(DNS)

"Slow and steady wins the race" they say.

They are wrong.

When it comes to website load times, every millisecond counts. For every 1000ms of additional latency, visitor satisfaction drops by 16%.


Every time I visited my selfhosted services (including this blog), I noticed that it would take ages to load on the first visit, but things were quite speedy after that. For a while, I chalked it up to some odd configuration on my personal device, but just yesterday I noticed it on my desktop PC as well. This PC is connected over Ethernet to my collage's network, which has excellent performance (most of the time), and no special configurations or weird brower settings.

I wondered what the hold-up was. Maybe some JS library is getting cached that takes a while to load. Perhaps a large font is being loaded in a blocking manner.

I tossed my blog into Pingdom Speed Test, which told me that it wasn't just me getting these long load times.

screenshot of pingdom tools website speed test, with orange arrow pointing to the "Load Time" section, pointing to 2.10s

So... what exactly is the holdup?
Images? Fonts? Libraries? Something else?

The problem, as usual with this sort of thing, was DNS.

screenshot of pingdom tools waterfall, showing 1202.7ms of DNS latency

Yikes.

My DNS provider is Cloudflare, but something tells me that Cloudflare isn't the holdup.

screenshot of cloudflare DNS screen. 2 CNAME records, one with a wildcard and the other with root, both pointing to bobrobot.duckdns.org

Yes, I use a DDNS provider. I cannot be arsed to set up a script to auto-update the Cloudflare DNS settings.

Just to make sure that my DDNS provider was, in fact, the issue, I threw their homepage into Pingdom to double-check.

screenshot of pingdom waterfall, 957.2ms DNS

Yep. DuckDNS is the issue. Hosted on AWS my ass. That has got to be the slowest AWS server I have ever seen. What are they hosting it on, S3 Glacier Deep Archive??

screenshot of DuckDNS homepage, which says "free dynamic DNS hosted on AWS"

I do feel bad holding a completely free service to such a high standard, but still, a >1s DNS response is pretty bad.

screenshot of text, "DuckDNS.org - We provide a free dynamic DNS hosted on Amazon EC2 - Most connections to the internet are through a dynamic external IP address which changes quite often (weekly or even daily), this can make it very difficult to connect to home services from an external computer."
I wonder what their EC2 bill is like

Anyway, I realized that my "dynamic" residential IP hasn't changed in over a year, and that's close enough to static for me to just set it normally in the Cloudflare dashboard. I'll update it myself next time my IP updates.

screenshot of DNS records page. 2 A records point to 24.24.179.204

The results speak for themselves.

screenshot of pingdom tools, 423ms load time

And the waterfall is even more dramatic...

screenshot of waterfall, 17.9ms DNS latency

That is a 98.51% reduction in DNS latency. Absurd. The whole website loads in under 0.3 seconds, not including fonts, which push it up to 0.42s. Overall, it's 5X faster than before. If you use DuckDNS, I would recommend either making a script to update the CF DNS configuration or just updating it yourself.