| 场景 | 接口 502/504/超时 |
|---|---|
| 组合 | curl -w 耗时 + --resolve 直连 + tcpdump |
耗时分解
耗时分解
curl -sS -o /dev/null -w 'dns=%{time_namelookup} conn=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total} code=%{http_code}\n' --max-time 15 https://api.example.com/health直连后端对比
直连后端对比
curl -sS --resolve api.example.com:443:10.0.0.9 -o /dev/null -w 'code=%{http_code} total=%{time_total}\n' https://api.example.com/health
curl -sS -o /dev/null -w 'code=%{http_code} total=%{time_total}\n' http://10.0.0.9:8080/health # 后端本机直测旁证
旁证
ss -tn state established '( dport = :8080 )' | wc -l # 后端连接数(后端机上)
tail -n 50 /var/log/nginx/error.logttfb 高 + 后端直测也慢 → 应用问题;前端慢后端快 → 网关/网络问题;cert 报错先跑 openssl s_client。