<img alt="" src="/secure.intelligence-enterprise.com/785851.png" style="display:none;">

What is Network Latency and How to Measure It?

April 30, 2024
Building commercetools Extensions

What is Network Latency and How to Measure It?

Latency, in the world of networking, refers to the time it takes for a request to travel from a user to a server and for the response to make its way back to the user. This delay is a critical factor in determining the performance of web applications, especially in today's digital landscape where cloud-based services and the Internet of Things (IoT) play a central role. In this article, we'll delve deeper into the concept of network latency, its significance, and how you can measure and reduce it.

What is Latency?


Latency encompasses various factors contributing to the time it takes for data to traverse the network. When a user initiates a request, the initial latency includes DNS lookup, TCP handshake, and TLS negotiation. Subsequent requests benefit from established connections and cached information, resulting in lower latency. Modern protocols like HTTP/2 and HTTP/3 further optimize latency compared to the older HTTP/1.1 protocol.

Caching at the browser, CDN Edge and the origin server side will also play a role in the latencies of repeated requests. Caching will result in lower or near-zero latencies. Care must be taken to understand the conditions to ensure a fair comparison.

Latency is also a measure of the quality of the network at the client side, as it is for the CDN. While comparing two CDN systems, it is best to ensure the conditions are similar for both CDN. This can usually be achieved by making a few warm-up requests on both networks before recording the measurements. The comparative tests should also be done as close to each other as possible to reduce the probability of network conditions changing. It is better to conduct interlacing tests wherein a set of requests are made to each network, alternatively, a few times.


Why is Latency Important?


As businesses increasingly rely on cloud-based services and IoT data for real-time operations, high latency can lead to inefficiencies. Additionally, poor latency can negatively impact user experience and customer satisfaction, even if companies invest in costly network infrastructure.


How can Latency be Reduced?


The use of a CDN (content delivery network) reduces latency significantly. CDNs cache static content and serve it to users. By distributing servers across multiple locations, CDN servers can store content close to end users and deliver it to them more quickly. Therefore, websites will load faster and perform better.

Performance can also be slowed down by factors other than latency. Web developers can decrease the amount of render-blocking resources (for example, by loading JavaScript last), optimise images and videos for faster loading, and reduce file sizes.

By deliberately loading some assets first, it is possible to enhance the perceived page performance. Above-the-fold content refers to what displays in a browser window before the user scrolls down. A webpage can be set up to load this content first so that users can start engaging with it even before it has finished loading. Additionally, assets can be loaded only when they are required by a web page using a method called lazy loading. These methods do not really reduce network latency but enhance the user's experience of page speed.


Tools to Measure Latency



A ping-based test is a good measure of network latency. However, it will not provide a reasonable measure in the context of web pages, primarily since PING does not use HTTP-based protocol, whereas web pages do.

Curl or Wget

Both Curl and Wget command line tools can be used to initiate a test from the local computer or a server. These tools are easier to execute one request at a time and may require scripting to run multiple requests and capture the statistics.

Browser Developer Tools (F12 mode)

Chromium-based browsers, Google Chrome, and Microsoft Edge, provide more accessible ways to observe the details of a webpage request. This mode can provide details of latencies observed for all requests a web page makes. Usually, the first request is for the web page, and the subsequent requests are for its assets like images, CSS etc.

Sometimes, the web page has redirects. Hence, care must be taken to ensure that for comparative testing, redirects should be avoided. Further, if HTTP/2 or HTTP/3 protocols are being used, then the latencies observed in the subsequent requests may be a challenging comparison. These modern protocols execute multiple requests in parallel towards maximising throughput, and the individual requests may have skewed data. If latencies of assets like images need to be measured, then instead of a web page, the direct URL of an image should be used in the browser window. This will ensure to avoid the complexities of the modern protocols.

As only one web page can be viewed in a browser, this tool suits single-page observations rather than automated multiple requests.

Apache Benchmark (ab)

Apache Benchmark is an open-source command line tool that can initiate a test from a local computer or a server. It provides means to initiate multiple requests while recording the statistical summary of the results observed. More information and details of options can be found here.

Web Vitals (TTFB/FCP/LCP etc.)

Web Vitals refer to a set of metrics designed to quantify the performance experienced by web page users. Most notably, Time-To-First Byte (TTFB), First-Contentful-Paint (FCP) and Last-Contentful-Paint (LCP) are good indicators of the latency of a web page.

Web Vitals can be measured using synthetic test harnesses like Google Pagespeed Insights, GTMetrics or Web Page Test. Care must be taken to ensure the test conditions are identical while comparing the two networks. We recommend Web Page Test as it provides much better control over the conditions than others while offering the service at the free pricing level. It will be a good idea to repeat the test a few times to ensure better comparison.

Real User Measurement (RUM) tools can also measure Web Vitals. Nitrogen RDx is one such tool providing unprecedented statistical analysis across data collected from 100% of the real users visiting the websites.

CDN Perf

You can test the latency of your CDN or server from all over the world with this benchmark tool. All tests run in real-time from 200 available locations around the world. You can use this tool to compare CDN providers and their performance in different regions. As well as debug your own routing logic and geo load-balancing. Results are stored for 30 days.




In an era where online speed and efficiency are paramount, understanding and managing network latency is crucial. By leveraging CDNs, optimizing web assets, and using the right measurement tools, you can ensure that your web applications and services deliver a seamless user experience. Lower latency translates to happier users and better business outcomes.


Explore N7 - The Nitrogen Platform, offering solutions to reduce network latency and enhance user experience. Create your FREE N7 account today to get started!