Slow request? Measure it with one curl line
Stop arguing about the network. This curl line breaks down DNS, connect, TLS and server time.
Published here · 1 source · Resume reading
Stop arguing about the network. Measure it.
The one-liner
curl -s -o /dev/null -w 'dns %{time_namelookup} connect %{time_connect} tls %{time_appconnect} ready %{time_pretransfer} first-byte %{time_starttransfer} total %{time_total} code %{http_code}\n' https://example.com/How to read it
Every number counts from the start of the request, so read the gaps:
| Gap | What it tells you |
|---|---|
| dns big | Slow name lookup (resolver) |
| connect minus dns | Reaching the host |
| tls minus connect | TLS handshake (0 on plain http) |
| first-byte minus ready | The server thinking, plus one network round trip |
| total minus first-byte | A big or slow response |
Example output
A server that waits 1.5 seconds before answering:
dns 0.000008 connect 0.000241 tls 0.000000 ready 0.000255 first-byte 1.505788 total 1.505824 code 200Everything near 0 until first-byte. That is the server.
Make it reusable
Put the format string in a file called timing.txt:
dns %{time_namelookup} connect %{time_connect} tls %{time_appconnect} ready %{time_pretransfer} first-byte %{time_starttransfer} total %{time_total} code %{http_code}\nThen run:
curl -s -o /dev/null -w @timing.txt YOUR_URLSame output, one short command, reusable on any URL.
Send this to the teammate who blames the network every time a request feels slow.
Keep this guide
Filed under Dev tools
Questions about this guide
Why is first-byte minus ready the server time?
It includes the server thinking plus one network round trip. Compare it with connect minus dns to separate network from server.
Can I reuse this on any URL?
Yes. Put the format string in a file and run curl -s -o /dev/null -w @timing.txt YOUR_URL.