DEV Community

Discussion on: Explain DNS TTL Like I'm five

Collapse
preciselyalyss profile image
Alyss 💜

Your grandma wants to make sure she knows where you're at and how you're doing. She then calls the rest of the family to let them know. Would you prefer she call every day or every 2 minutes?

In this case, your grandma is the authoritative nameserver. The nameserver has to reach out as often as you tell it there might be an update. Getting a call every 2 minutes probably interrupts something in your daily life (and equally can cause delays) when someone requests your site. Using the grandma analogy, she's still trying to update the rest of the family to keep the information from getting stale.

The analogy is a little rough, but hopefully that gives you a more concrete example.

Collapse
peter profile image
Peter Kim Frank Author

Is it a best practice to only have my grandma call every two minutes if I'm aware there might be some family emergency she should know about? "Uncle Tim is going in for surgery — ping me every two minutes to see how he's doing" type of thing?

Is there a risk that by having her call every two minutes, every day, forever, that she could jam up my phone line for other important calls? Or is it just not a good practice if it's not necessary to be a good-citizen of the other users of this telecom?

Thanks for the explanation! Super interesting stuff.

Collapse
preciselyalyss profile image
Alyss 💜 • Edited on

It is really dependent on your needs. I have historically done 24 hours, but needed to temporarily change it to 20 minutes because I'm deploying a new microsite, trying to update some other minor feature that relies on DNS records, etc. As a result, I had to wait 24 hours after I set it to 20 minutes in order for the update to take place.

Best practice for making a change: if your TTL is X, then X units of time before you need to make a change, update it to 5 minutes.

A higher TTL reduces the perceived latency of a site and decreases the dependency on the authoritative name servers. It isn't necessarily jamming the phone line, which is where the analogy fails. It takes more hops to get the correct nameserver information back thus the increase in perceived latency. A longer TTL/less perceived latency means the information has been cached on a nameserver (non-authoritative) that is a shorter hop between the end-user and DNS information that isn't yet stale.