Operations 7 min read

Diagnose HTTP Service Latency with httpstat: A Step‑by‑Step Guide

Learn how to install Go, set up the httpstat tool, and use it to break down HTTP request phases—DNS lookup, TCP connection, TLS handshake, server processing, and content transfer—to quickly pinpoint network or service latency issues.

ITPUB
ITPUB
ITPUB
Diagnose HTTP Service Latency with httpstat: A Step‑by‑Step Guide

When Service A calls Service B and encounters a timeout, it can be unclear whether the problem lies in the network or the target service; a detailed timing breakdown helps pinpoint the cause. The httpstat tool, similar to curl, displays the duration of each request phase such as DNS resolution, TCP connection, TLS handshake, server processing, and data transfer.

Installing the Go environment

Because httpstat is written in Go, you first need a working Go installation. On a macOS M1 machine, download the tar.gz archive from the official site, extract it, and configure the environment variables:

cd /Users/ulric/works/tgz
wget https://go.dev/dl/go1.22.2.darwin-arm64.tar.gz
tar -zxf go1.22.2.darwin-arm64.tar.gz

Set the directories and update PATH:

export GOROOT=/Users/ulric/works/tgz/go
export GOPATH=/Users/ulric/works/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Persist these lines in ~/.bash_profile or ~/.zshrc so they load automatically for each terminal session. Verify the installation with: go version Expected output: go version go1.22.2 darwin/arm64.

Installing httpstat

With Go ready, install httpstat directly from its repository:

go install github.com/davecheney/httpstat@latest

The command downloads the source, compiles it, and places the binary in $GOPATH/bin, making httpstat available from the command line.

Using httpstat

Run httpstat --help to see all available options, many of which mirror curl (e.g., -X for method, -H for headers, -d for request body, etc.).

Example with curl:

curl -X POST -H "Content-Type: application/json" -d '{"service": "tomcat"}' 'https://httpbin.org/post?name=ulric&city=beijing'

Now the same request with httpstat:

httpstat -X POST -H "Content-Type: application/json" -d '{"service": "tomcat"}' 'https://httpbin.org/post?name=ulric&city=beijing'

The output shows the HTTP response headers followed by a concise timing chart:

Connected to 34.198.16.126:443

HTTP/2.0 200 OK
Server: gunicorn/19.9.0
...
Body discarded

DNS Lookup   TCP Connection   TLS Handshake   Server Processing   Content Transfer
[  11ms |      217ms |      446ms |        570ms |          0ms ]

This visual breakdown makes it immediately clear which phase consumes the most time, aiding rapid diagnosis of latency problems.

Conclusion

By installing Go, compiling httpstat, and using its detailed timing report, developers and operators can quickly identify whether delays stem from DNS lookup, network connection, TLS negotiation, server-side processing, or data transfer, streamlining troubleshooting of HTTP service issues.

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.

Backendcommand-lineNetwork LatencyHTTP debugginghttpstat
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.