Network Latency: How to Measure, and Optimize for Speed?

Network Latency

When it comes to improving the loading speed of the site, one must take care of every optimization that is possible.

One of the factors is Network Latency Optimization, which is often ignored.

In this article, we will dive deeper into the latency. 

What is network latency?

Network Latency is a time taken by the data to travel across a network, and back again to source.

A network sends a request to the server to receive the data. The request transmits at a speed of light, and brings back the requested content, i.e. requested data packets.

What is Network Latency?

In simpler and border terms, when you load a webpage in the browser, the HTTP sends the requests to the server. The server reads the header request and returns the data, which then is parsed in the browser.

The time it takes by the information to move across the entire network & proxies are known as Network Latency.

We measure the round trip under the network latency because computers do not initiate a new TCP connection until the previous one is completed. So until the requested data arrives, the browser waits before creating a new request.

Though the speed of data transmission is high (similar to the speed of light), there are still lots of hurdles that contributes to the network latency time. 

Causes of Network Latency:

Network Latency depends on two major factors—geographical distance and proxies (communication equipment).

The more there is the distance between the two points, the more will be the latency time in transmission of the data.

Also, there will be more points of equipment to jump and regulate the data.

Let’s understand the causes in more depth:

Distance between Source and Destination

The biggest reason for high latency time is often the large distance between the user and the webserver. Due to the large distance, most of the network uses electrical signals, light waves, or wireless instead of cables, and fiber optics. Wireless networks show high latency time in comparison to wired networks. 

Moreover, huge distance also means multiple layers of network equipment, many routers, and bridges. The data has to jump various connections and change bridges. The task of hoping to a new device is time taking, and adds up into the latency time. As the number of devices increases, lookup time also increases.

Bottlenecks

Multiple devices are used as bridges to transmit the data from one point to another. Not all the network links have the same capacity to transport data.

One network link can easily handle data at a rate of 1 GBPS, while the other one can struggle with it. Then there are private WAN and VPN tunnels that data has to go through.

At any point in the network, data can experience a link where the data throughput capacity is low. Hence, the packages are either dropped or queued. In both cases, it delays the transmission and increases network latency. 

As the TCP must receive the data before sending the new request, it retransmits the data, which pile up in the buffering process—overall increasing the latency time significantly.

Ineffective QoS

QoS or Quality of Service means prioritizing the critical data, so it does not end up in the queue, and pass quickly. The network gives such data priority while transmitting, and moves it quickly without making it wait at any point.

But if the QoS are not correctly configured and set up, networks will treat all the data as the same. So at bottlenecks, and other congestion points, both critical data, and non-critical data will be waiting in the queue according to their time of arrival.

Ineffective QoS does not increase latency time, but it affects the transmission of critical data.

Propagation Time

It is merely the time it takes for the data to cover the distance between two points. It can never be zero as, if there is a distance, travelling will consume time to cover it. However, it can be closer to zero.

If the data packets are heavy, and then the propagation time will be more. Sometimes, a web server does not have enabled Gzip compression, making the packets super heavy.

How to measure Network Latency?

Network Latency is calculated in milliseconds. Two metrics are observed for the latency time measurement. RTT and TTFB.

RTT: Round Trip Time: It is a more common and popular way of measuring Network Latency. It accounts the time it takes to transfer a data packet from one point to another, and then back to the source. The time it takes for the complete request-response cycle.

TTFB: Time to First Byte: It records the time it takes to get the first byte of data back to the source. It’s a point to point traction time.

RTT is a more popular way of measuring Network Latency because it does not require data collection point at the destination. A single point at the source is enough to measure the duration between the request sent and the response received.

Test Latency With Ping

Ping is a quick, simple and effective tool to measure the network latency. It is inbuilt in every computer and works on IMCP (Internet Control Message Protocol).

Typically, the network administrator uses ping to measure the network latency quickly, as it does not require any additional software. 

How to use Ping:

  • Go to the command prompt
  • Type ping (siteurl)
  • Enter
Test Network Latency With Ping

After you run the command, your computer sends 32 bytes of data to the siteurl, and calculates the time it takes to receive the response from the server.

As helpful and quick Ping is, it does not have a function to fix the issue or to pinpoint the bottlenecks. But other tools can help you in recognizing the problems.

Test Network Latency with Online Tools:

Site24x7 Ping Test

Test Network Latency With SIte24x7 Ping

Site24x7 offers a free Ping test for websites and servers. It provides the RTT time from multiple locations.

Check Now.

DotComTools Ping Test

Test Network Latency With DotComTools

DotComTools calculate the return time of more than 15 locations. It is also a free tool to ping the sites.

Check Now.

Ways to Reduce Latency:

Use a CDN

CDN decreases the latency by reducing the geographical distance between the user and the server. 

When the traffic is arriving from all parts of the world, you have to have data centres around the globe. It means having to host in multiple countries, and hosting a copy of your data at those hosting, which is not feasible for every online business.

That’sThat’s why there is CDN. Content Delivery Network is a network of PoPs spread across the world. Once implemented, each PoP gets a mirror copy of your site.

When the visitor requests a page, the data transfers from the nearest CDN PoP, effectively decreasing the distance between the user and the central server.

As the distance is reduced, latency time drops too.

HTTP/2

Nearly 70% of the web is running on HTTP 1.1, which is a 20-year-old technology, and it is still working excellent. However, the high latency rate is a severe problem.

With the emerging web development tech, the webpages are combining several types of data. The page is made up of Java, CSS, HTML, PHP etc.… Each time HTTP has to fetch an asset; a new TCP connection is formed. HTTP/2 solves this problem.

HTTP/2 reduces latency by reading a single TCP connection to continue the request-response cycle. It minimizes the number of data trips from sender to the receiver, with parallelized transfers. 

HTTP/2 brings a significant difference in latency rate.

Decrease external HTTP requests

Modern websites have lots of third party scripts coded into them. They do the task of recording, analyzing, and understanding the user behaviour on site. Some codes run ads; some does the maintenance of the website. 

Having lots of third party scripts on the site negatively affects the loading speed. Each external HTTP request has its own latency time, which contributes to the overall page latency time. Though most of the quality third party services use CDN, still we measure latency in ms, and each ms counts.

Always test the third party scripts loading speed before installing it on your site. Make sure the service is hosted on robust infrastructure.

Caching

Browser caching can also reduce latency time as the browser does not have to receive the static content from the server.

Modern browsers are powerful and apt to store the site’s data to the cookies. When the user loads the URL again, the browser can match the server content to the browser content with the help of e-tags, and if it matches, they load it from the cookies.

It’s an effective and straightforward method. Check out the best caching plugins to implement this on your site.

DNS prefetching

DNS prefetching is a simple concept yet improves the speed of the site. In prefetching, the browser performs DNS lookups in the background for all the links on the given webpage. 

This way, DNS lookup is already taken place before the user even clicks on any link. Though this method impacts the bandwidth, as the browser prefetch the DNS for all the links present on the page, while the user might only click on a single link.

DNS prefetching can be added to a specific URL by adding the rel= “DNS-prefetch” tag to the link attribute.

Preconnect

Preconnect is one step ahead of the prefetching. Prefetching only prefetches DNS, while preconnect includes DNS lookup, TLS negotiations, TCP handshakes. 

This saves a considerable amount of time while loading the page for the users.

Hosting

Powerful web hosting can solve the majority of your problem related to the speed of the website. Premium hosting providers offer CDNs, HTTP/2, and server-side caching.

At ServerGuy, we guarantee a 3 second load time, be it WordPress or Magento.

We will tune the hosting so it will complement your project, and the platform will be able to run at its true potential.

Wrap Up

In this article, we learned about the network latency time and optimization strategies.

I hope you can reduce latency time of your site by following the optimizations. Though it is impossible to tone it down to zero, as there will always be some latency, it can be minimized. 

As the loading speed of the site is critical for conversion, SEO, and keeping the visitors onboard, it is necessary to optimize the speed wherever possible.

If there is any other way to reduce the network latency, please leave it in the comments. I will add it to the article with credit.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new modules, and more. 100% Magento Goodness, a promise!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

We can help you. Right now.

Fast growing merchants depend ServerGuy for high-performance hosting. Experience counts. Let's get started.

Talk to a sales representative

USA / Worldwide

+1.714.2425683

India

+91.9852704704