Measure Time to First Byte (TTFB) with curl -w
Measure time to first byte with curl -w and the time_starttransfer variable, next to connect and total time. A server that waits five seconds shows it in that figure.
A request feels slow and you want to know whether the time goes to connecting, waiting for the server or downloading.
fmt='connect %{time_connect}s first byte %{time_starttransfer}s total %{time_total}s\n'
curl -s -o /dev/null -w "$fmt" localhost:8000/
curl -s -o /dev/null -w "$fmt" localhost:8000/slowconnect 0.000153s first byte 0.000665s total 0.000726s
connect 0.000063s first byte 5.000963s total 5.001122s-w prints variables after the transfer, so the three used here split the time. time_connect is when the TCP connection was ready, time_starttransfer is when the first byte of the response arrived, and time_total is the end. For the fast path all three were under a millisecond. For the slow path the first byte arrived at 5.000963 seconds and the total was 5.001122, which says the server was waiting and the download took no time. See --write-out in the manual.
time_starttransfer also contains DNS lookup and the TLS handshake on a real site, so subtract time_pretransfer to get the pure server wait. One measurement is noisy; repeat it and compare medians. A local server like this one hides network latency completely.