Full Byte Developer.

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

Stop arguing about the network. Measure it.

The one-liner

bash
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:

GapWhat it tells you
dns bigSlow name lookup (resolver)
connect minus dnsReaching the host
tls minus connectTLS handshake (0 on plain http)
first-byte minus readyThe server thinking, plus one network round trip
total minus first-byteA big or slow response

Example output

A server that waits 1.5 seconds before answering:

text
dns 0.000008 connect 0.000241 tls 0.000000 ready 0.000255 first-byte 1.505788 total 1.505824 code 200

Everything near 0 until first-byte. That is the server.

Make it reusable

Put the format string in a file called timing.txt:

text
dns %{time_namelookup} connect %{time_connect} tls %{time_appconnect} ready %{time_pretransfer} first-byte %{time_starttransfer} total %{time_total} code %{http_code}\n

Then run:

bash
curl -s -o /dev/null -w @timing.txt YOUR_URL

Same 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

By Full Byte Developer

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.

Sources

Next in this stack