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.
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:53107Explanation
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”.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
