Diagnose a slow HTTP API

Performance

An endpoint feels slow and you need evidence before changing code.

  1. Measure total timings

    curl -s -o /dev/null -w 'dns=%{time_namelookup} connect=%{time_connect} ttfb=%{time_starttransfer} total=%{time_total}
    ' https://api.example.com/health
  2. Inspect response headers

    curl -I https://api.example.com/endpoint
  3. Trace DNS resolution

    dig +short api.example.com
  4. Correlate app logs

    grep 'request_id=<id>' /var/log/app.log

Notes

  • Compare fast and slow requests with the same payload.
  • Check if latency is network, app, or database bound.

Related commands: curl -w, dig, grep

Related workflows: Ask an agent to investigate a performance issue