Skip to main content

DNS Lookup time

core web vitals frontend
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

What Is a DNS Lookup Time?

Before defining a DNS lookup, you first need to understand how DNS works.

DNS stands for Domain Name System, a server or set of servers that store a record of domain names and their associated IP addresses.

A domain is the name of a website that is typed into a web browser. When that happens, your computer does not know which server to talk to based on the text you just typed. It needs the IP address of the server that hosts the website or application. 

For example, if you type in www.example.com into your web browser, your computer needs the IP address of the server (or servers) that host the website. This is where a DNS comes into play.

DNS is often compared to a phone book for the world wide web, where your computer knows the website’s name but needs help looking up the number – the IP address. Similarly, your computer sends a request containing the website’s domain name to a nearby DNS. DNS lookup is the process the DNS goes through to find the IP address of the given domain and return it to your local computer.

With that information, your computer can now establish a secure connection with the desired server and begin sending and receiving data.

What Is DNS Lookup Time?

DNS Lookup Time is the time it takes a Domain Name Server to receive the request for a domain name’s IP address, process it, and return the IP address to the browser.

What Is a Good DNS Lookup Time? 

The average DNS lookup time is between 20 and 120 milliseconds. Anything between that and under is generally considered very good.

How to Reduce DNS Lookup Time

There are several ways to minimize and improve your DNS lookup time. There is no universal solution, but there are a few common ones that work for most people.

1. Cache Files Locally

To reduce the DNS lookup time, you have to decrease the number of times you request a resource from a third-party domain. You can do this by actively looking through the number of resources you load to determine if they are necessary to render the site or if the cost/benefit ratio makes sense. If they are not, or they’re not worth it, remove them.

Sometimes you’ll find resources that you can’t remove from the site. In this case, you can try to cache them locally to avoid going through another DNS lookup process. This simple exercise can work well for icons, CSS files, fonts, images, videos, etc. While caching JavaScript files might be your next thought, it’s often considered bad practice to do so. JavaScript is often updated, so you would lose the ability to get the latest updates automatically.

2. Minimize the Number of CNAME Records

CNAME records generate additional DNS lookups, which will result in more waiting time. Having CNAME records is perfectly normal, and more often than not, you are forced to have at least some. However, having too many can add a significant amount of load time. Ensure that all the records you currently have are needed and worth the time penalty. For the ones that you’ll keep, try to optimize them as much as possible.

For example, you could optimize the CNAME records with an ANAME record. It’s faster and has the same functionality as the CNAME but at the root level.

While some may consider CNAME optimization as a micro-optimization not worth the time, it’s important to remember that having too many CNAMES can result in an SRVFAIL even if there is no loop.

3. Use a Fast DNS Provider

You can optimize slow DNS lookup times by upgrading to a faster DNS provider. 

Not all Domain Name Servers are created equally. One key component that contributed to DNS lookup time is the physical DNS. Certain DNSs are slower than others or experience more heavy traffic. In some cases, it may make sense to designate a specific DNS. 

By default, users’ computers may look for your domain information on a server that is far away from the physical servers. While taking multiple trips around the globe on fiber optic cables may be fast, those milliseconds do add up over time.

There are many DNS options available; some work better than others. Free DNS options are often slow, while premium DNS providers generally have faster response times. They have extensive infrastructure and data centers around the globe, which will minimize the impact DNS lookups have on website speed.

4. Defer JavaScript Files

More often than not, JavaScript files load third-party assets resulting in high DNS lookup time and increased overall page load time. 

One easy method to improve your DNS lookup time is to defer parsing your JavaScript until users need it. Deferring the parsing of JavaScript won’t reduce the number of DNS lookups required but delaying the loading of non-critical files will help users perceive a better performance. So if you have code that has to run only when filling a form at the bottom of the page, don’t load it until the users have to use it. 

Here’s an example:

<script defer src="script.js"></script>

While this technique sounds like a good idea for minimizing DNS lookup time, you need to be careful with it. Avoid using an excessive number of DNS prefetching as they can cause severe performance issues. You should double-check to make sure you aren’t prefetching to the same domain or subdomain.

5. Use DNS Prefetching

DNS prefetching is a resource hint that allows you to perform DNS lookups in the background, as the user reads the current page before making another request. This is used for links within the content. It can reduce DNS lookup time and improve website performance since you end up using idle time to get a resource so that when the user does click on the link, it will load significantly faster. 

Example: <link rel=”dns-prefetch” href=”https://domain_to_prefetch.com/”>

6. Monitor Your DNS Lookup Time

The easiest way to understand how DNS lookup times influence website performance is to benchmark your website constantly. This will give you a better idea of what needs to be improved and where the bottlenecks are. For this, you need a monitoring tool that allows you to record your website’s load times. Choose one that can measure more than DNS lookup times since you must track other key website metrics as well if you want to ensure the overall performance of your website.

Monitoring DNS Lookup Time with Sematext

Sematext offers a suite of monitoring solutions that will help you keep an eye on your entire stack, allowing you to focus on the more important aspects of your business. One of the products is Sematext Experience, a real user monitoring tool that offers a simple way to track your DNS lookup time and other important website performance metrics like your TTFB, FCP, CLS, and many others more.

You get started with Sematext for free for 14 days or pick one of the many tiers that will perfectly fit your needs.

Start free trial


See Also

Stay up to date

Get tips, how-tos, and news about Elastic / ELK Stack, Observability, Solr, and Sematext Cloud news and updates.

Sematext Newsletter
Create Status Page with Synthetics! Learn more