主 题:curl 请求很慢?把 DNS、连接和 TLS 耗时拆开看
发 布 者:jirry
标签分类: 技术
时 间:2026-10-14 22:16:12
内容预览:接口慢时,只看总耗时不容易定位。curl 可以把几个关键时间点直接打出来:curl -o /dev/null -s -w 'dns:%{time_namelookup}\ntcp:%{time_connect}\ntls:%{time_appconnect}\nttfb:%{time_starttransfer}\ntotal:%{time_total}\n' https://example.com这些值是从请求开始累计的时间点。DNS 阶段看 time_namelookup;TCP 建连大致看 time_connect - time_namelookup;HTTPS 握手看 time_appconnect - time_connect;服务端和上游响应可看 time_starttransfer - time_appconnect。最好连续跑几次,并换个网络或地区对比,避免被单次抖动误导。
直达链接: https://www.nodeseek.com/post-983842-1
 
 
Back to Top