Operations 2 min read

How to Use cURL to Measure Web Request Timings and Diagnose Performance Bottlenecks

This guide shows how to configure a .curlrc file and use cURL’s timing variables to capture DNS lookup, connection, TLS handshake, transfer start, total time, and download size, enabling precise performance analysis of web requests.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How to Use cURL to Measure Web Request Timings and Diagnose Performance Bottlenecks

cURL is a powerful web request tool that can also measure request timings.

Practice

Create a curl configuration file (~/.curlrc) with the following content:

# Content (long, can scroll)
-w "dnslookup: %{time_namelookup} | connect: %{time_connect}
appconnect: %{time_appconnect}
pretransfer: %{time_pretransfer}
starttransfer: %{time_starttransfer}
total: %{time_total} | size: %{size_download}"

Use the configuration with a curl command, for example: $ curl -so /dev/null https://www.zasag.mn The output will display timing values such as:

dnslookup:1.510
connect:1.757
appconnect:2.256
pretransfer:2.259
starttransfer:2.506
total:3.001
size:53107

Explanation

The following timing variables are reported:

time_namelookup – DNS lookup time.

time_connect – Time to establish a TCP connection to the web server.

time_appconnect – Time to complete the TLS handshake.

time_starttransfer – Time until the client receives the first byte of the response.

time_total – Total time until the client closes the connection.

These metrics help you understand the details of the request process and identify performance bottlenecks.

Content is adapted from Cloudflare’s blog post “A Question of Timing”.

cURL timing variables diagram
cURL timing variables diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

networkcURLdiagnosticstiming
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.