You have probably done a lot of things to speed up your website. And one of the things affecting your website load time is related to DNS Lookup which is dependent on the performance of DNS servers. So, here we are talking about DNS servers and how they affect website speed.
DNS servers or DNS name servers affect your website speed because they need to tell where the website for any particular domain name is located on the internet. And the time they take in doing so adds up to your website load time. Here is what I mean and what you need to do about it.
What is DNS?
DNS or Domain Name System is the process of linking a domain name with an IP address. This linking is necessary because computers need IP addresses to connect to other computers and in this case, load websites stored in other computers. For instance, when you type the domain name example.com in your web browser, it will need to connect to the linked IP address 22.214.171.124 where the website is hosted so that it can load the website for you.
This way, DNS allows us to use domain names instead of remembering IP addresses to visit different websites on the internet.
What are DNS records?
DNS records are the individual information about a domain name that tells about the location of various services for the domain. For instance, a DNS record can be used to point a domain name to an IP address where the domain’s website is being hosted. There exist several types of DNS records like A, CNAME, MX, TXT, etc. which are used to accomplish different purposes. For instance, you can use A records to tell web browsers where the website for your domain name is being hosted. Additionally, you can use MX records to tell who should receive the emails on behalf of your domain name.
What is a DNS Server or Name Server?
DNS Servers or Name Servers are the machines that store DNS records and respond to DNS queries to help web browsers find IP addresses associated with different domain names. There are different types of DNS servers like Recursive DNS Server, Root DNS Server, TLD Name Server and Authoritative DNS Server that work together to resolve domain names into IP addresses.
What is DNS Lookup and How Does It Affect Website Speed?
DNS lookup is the process of finding IP addresses using domain names. This is important because web browsers need IP addresses to load any website for us but all we give is a domain name. Therefore, a browser first needs to find the right IP address before it can show us the website for any given domain name. For instance, when you type a domain name like example.com and press enter into your browser, it goes through a process to find the IP address associated with the domain name and only after it finds the IP address, which in this case is 126.96.36.199, it can start connecting to the website for you. That’s why the time it takes to find the IP address associated with a domain name gets added to the total website load time.
How does DNS lookup work?
If you have ever wondered how people find websites on the internet by using domain names or website names, then DNS lookup is the answer for you. After typing a domain name into your web browser and pressing enter, the browser starts to find an IP address that is linked to that domain name so that the browser can load the domain’s website by connecting to that that IP address. Below is a description of how a browser finds the IP address for any domain name.
Browser’s Cache Memory
In order to find the IP address associated with a domain name, a browser first checks its own cache memory to see if it knows the IP address. The browser may already know the IP address for the domain if it has visited the site recently and stored the IP address in its cache memory. And if it does know the IP address, it will start connecting to that IP address to load the website for you.
Operating System’s Cache Memory
But if the browser doesn’t know the IP address, it will then check the DNS cache memory of your computer’s operating system. The operating system may already know the IP address if it has visited the site recently and stored the information in its cache memory. And if the IP address is found, your browser will start connecting to the IP address to load the website.
Recursive DNS Server
If the IP address isn’t found in either the browser or the operating system’s cache memory, the browser will send a query regarding the domain’s IP address to the Recursive DNS Server. Recursive DNS Server is also known as Resolver DNS Server and it is the DNS server that is generally provided by your ISP or Internet Service Provider which is the company from whom you buy your internet connection. However, you choose to use someone else’s recursive DNS server like Google Public DNS, CloudFlare’s 188.8.131.52, OpenDNS and so on. The recursive server may already know the IP address if someone else using that server has recently visited the site and the IP address has been cached in the server. And if found, the server will send the IP address to your operating system and from the operating system to your browser which will then connect to that IP address to load the website.
Root DNS Server
If the recursive DNS server doesn’t find the IP address for the domain, it will send a query to the Root DNS Server which sits at the top of the DNS server hierarchy. Root DNS server doesn’t store the IP addresses for specific domain names but it stores the information of the TLD name server where the recursive server should look next.
There are over 1,000 different root servers around the world that use a network of 13 different IP addresses. These 13 IP addresses are operated by 12 different organizations where Verisign is the only organization that operates two IP addresses. Verisign is also the registry or provider of the domain extensions .com, .net and some others.
TLD Name Server
TLD servers sit below the root server in the DNS server hierarchy. TLD stands for Top Level Domain and it denotes the domain extensions like .com, .net, .org, and so on. Therefore, if the DNS query is about example.com, the root server will point the recursive server to the .com TLD server. Then again, the TLD server doesn’t store information about IP addresses for specific domain names but it knows about the Authoritative DNS server where the resolver server can find the IP address it is looking for.
Authoritative DNS Server
Authoritative DNS Servers sit below the TLD server in the DNS server hierarchy and it is the place where you store all the DNS records for your domain name. Therefore, authoritative DNS servers are responsible for knowing all the DNS records for a domain name including the IP address that is being queried by the recursive server. That’s why the authoritative name server works as the final destination for the DNS query. So, when the resolver server sends the DNS query, the authoritative name server will respond with the IP address of the domain name.
Then finally the resolver server will send the IP address back to your computer’s operating system and then to your web browser for it to connect to the IP address and load the website.
The best thing you can do to ensure the quickest DNS resolution speed is to take advantage of DNS caching. DNS caching allows recursive DNS servers, operating systems and web browsers to store the IP address for your domain name in their cache memory so that they don’t need to go all the way to the authoritative DNS server every time they need to find your domain’s IP address. Therefore, DNS caching will accelerate the DNS resolution speed of web browsers for any subsequent times they need to connect to your domain.
You can use TTL or Time to Live to tell the recursive servers, operating systems and web browsers how long they should cache the IP address for your domain name. A high TTL value will allow your DNS records to be cached for a long period of time. But if you ever change the IP address associated with your domain name, high TTL value will make web browsers connect to your previous IP address for as long as the DNS cache period doesn’t expire. You can, however, overcome this problem by using a low TTL value or by reducing TTL value before you change the IP address.
Here is another great article about how DNS works that you can also check out to know more.
How to reduce the effect of DNS servers on website speed?
Because the DNS servers are responsible for resolving domain names into IP addresses, their speed of doing so affects the load time of any website. Therefore, in order to ensure a quick DNS resolution speed for your domain name, you can choose a hi-performing authoritative DNS server provider. In fact, Authoritative servers are the only DNS server type where you have the option to go with a provider of your choice. Whereas, the same root servers and TLD servers are entitled to be used by everyone in the world. This is why all you can do to maximize your website’s DNS resolution speed is to select a speedy authoritative server provider.
Don’t confuse an authoritative DNS server provider (also known as DNS hosting provider) with a web hosting provider. Web hosting is where you store your website’s contents or files like HTML, CSS, JS, image, etc. but DNS hosting is where you store your domain’s DNS records.
However, the difference in speed among various authoritative servers aren’t very noticeable and is generally limited to a few milliseconds to a few hundred milliseconds. Though the speed difference is very limited, a good authoritative server is still helpful to ensure nearly 100 percent, in not 100 percent, uptime and protect your website against DNS related attacks.
Additionally, you can use DNS caching to reduce the effect of DNS servers even more. In fact, when a domain’s IP address is already cached, the effect of DNS servers won’t matter at all because the browser won’t have to wait for the IP address to be delivered by the authoritative server. But because the caching can’t help with DNS resolution for the very first DNS query or the first DNS query after the cache TTL period has been expired, it is always better to go with a speedy authoritative server provider to always ensure a fast DNS resolution speed.
You can check out this article to know more about reducing DNS look up time caused by externally hosted files.
Which DNS Server Provider Should You Choose for Maximum Speed?
When I talk about choosing a DNS server provider, I mean choosing an Authoritative DNS Server provider because it is the only DNS server type where you have the option to select a provider of your choice.
When choosing an authoritative DNS server provider, you have quite a few options. For instance, you can choose the authoritative server of your domain registrar, web hosting provider, any third party provider or a private nameserver that you create yourself. Once you choose a provider, you can use their server to store your DNS records and one of those records will be used to point your domain name to the IP address where your website is being hosted.
However, depending on various reasons you can choose different providers. For instance, if you want to have the most convenience and don’t want to deal with creating and maintaining DNS records, you can go with the authoritative server provided by your web hosting provider. This is because when you add your domain name on your web hosting account, it generally creates the DNS records that will be necessary for your website to function properly. But if you go with any other provider, you will need to manually create your DNS records and update the records by yourself if there are any changes related to your domain or your web hosting account.
But if you want to focus on having fast DNS resolution speed, CloudFlare will be a good choice. Apart from providing one of the fastest DNS resolution speed, it ensures nearly 100 percent uptime and good security against some DNS related attacks. CloudFlare is proven to be one of the highest performing DNS server providers because of its massive network of more than 200 data centers around the world and its use of Anycast DNS for fast and reliable DNS resolution.
According to the test done by DNSPerf , CloudFlare takes about 10 to 15 milliseconds for DNS resolution which confirms it to be one of the fastest DNS server providers in the world. The site also checks its uptime to be around 99.99 to 100 percent making it very reliable.
Additionally, CloudFlare provides you with various types of securities other than those related to DNS and it provides some additional features like CDN, caching, website optimization, etc. that are very helpful to accelerate your website speed. And you can get to use all these benefits in their free plan.
Don’t confuse CloudFlare’s Recursive DNS Server (also known as CloudFlare’s 184.108.40.206) with its Authoritative DNS Server. CloudFlare provides both services. Authoritative DNS server is where you store your domain’s DNS records but the recursive DNS server is something your web browser uses to find IP addresses related to domain names.
Web browsers need IP addresses to connect with other computers so that they can load websites that are being hosted on those computers. DNS servers or nameservers help web browsers find IP addresses using the domain names that we give the browsers to connect to various websites.
In order to find the IP address from a domain name, a browser first checks its cache memory to see if it already knows the IP address. And if the browser does know the IP address, it will connect to that IP address and start loading the website for you. But, if the browser doesn’t know the IP address it will check in your computer’s operating system. If the IP address is found there, the browser will connect to that IP address otherwise it will send a DNS query to the Recursive DNS Server. If the recursive server knows the IP address it will send back the information to your computer’s operating system and then to your browser. However, if the recursive server doesn’t know the IP address, it will send a query to the Root DNS Server which will point the recursive server to the TLD Name Server to look next. Then the recursive server will send a query to the TLD server about the domain’s IP address. Then the TLD server will send the recursive server to the Authoritative DNS Server where the information can be found. Then after the recursive server sends a query, the authoritative server will reply with the IP address. After getting the IP address, the recursive server will send it to your operating system and then to your browser. Then your browser will connect to that IP address to load the website for the given domain name.
In order to reduce the time taken for this DNS resolution process, the recursive server, operating system, and your browser will store the received IP address in their cache memory. TTL or Time to Live can be used to tell how long this information should be cached so that if the IP address associated with a domain name is changed in the future, the browser doesn’t try to connect to the previous IP address.
You can choose any authoritative DNS server to store your domain’s DNS records so that people can find your website on the internet. The difference in speed among different authoritative servers aren’t very noticeable. Also, the impact of DNS servers on website load time can be minimized using DNS caching. But choosing a good DNS server provider will ensure that your website can always be found reliably and quickly on the internet. A good DNS server will also help your website against various DNS related attacks. CloudFlare is such a good authoritative DNS server that provides DNS server and some other important features like CDN, caching, website optimization, etc. for your website in their free plan.