惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
罗磊的独立博客
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
J
Java Code Geeks
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
N
News and Events Feed by Topic
腾讯CDC
P
Proofpoint News Feed
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
爱范儿
爱范儿
O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
D
Docker
Y
Y Combinator Blog
博客园 - 聂微东
G
Google Developers Blog
S
Security @ Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
S
Schneier on Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
CERT Recently Published Vulnerability Notes
I
Intezer
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
博客园 - Franky
博客园 - 三生石上(FineUI控件)
W
WeLiveSecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
Scott Helme
Scott Helme
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
LINUX DO - 最新话题
C
Cybersecurity and Infrastructure Security Agency CISA

NickChenyx's Blog

Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish
Create_Rubbish
nickChen · 2018-04-18 · via NickChenyx's Blog

curl 实战

Created At :

Count:402 Views 👀 :

  1. 耗时分析

耗时分析

$ man curl  # 查看 curl 的使用方式

-w, --write-out <format> # -w 参数配置输出格式

-w 参数中有部分时间相关的参数如下:

  • time_namelookup:从请求开始到 DNS 域名解析完成的耗时
  • time_connect:从请求开始到 TCP 连接建立耗时(三次握手)
  • time_appconnect:从请求开始到 SSL/SSH 等建立连接耗时( ssl handshake 等)
  • time_pretransfer:从请求开始到响应开始传输的时间
  • time_redirect:从请求开始到,包含前面四者耗时,且所有重定向的时间相加,直到最终访问目标服务前的耗时
  • time_starttransfer:从请求开始到第一个字节将要传输的耗时,包含了 time_pretransfer 耗时
  • time_total:请求的全部耗时

如何发起耗时分析请求

  1. 直接在命令行中拼写输出格式
    curl -w '\ntime_namelookup=%{time_namelookup}\ntime_connect=%{time_connect}\ntime_appconnect=%{time_appconnect}\ntime_redirect=%{time_redirect}\ntime_pretransfer=%{time_pretransfer}\ntime_starttransfer=%{time_starttransfer}\ntime_total=%{time_total}\n\n' -o /dev/null -s -L 'http://voidchen.com'
  1. 利用文件描述格式
    创建一个格式文件 format.txt
     time_namelookup:  %{time_namelookup}\n
        time_connect:  %{time_connect}\n
     time_appconnect:  %{time_appconnect}\n
       time_redirect:  %{time_redirect}\n
    time_pretransfer:  %{time_pretransfer}\n
    time_starttransfer:  %{time_starttransfer}\n
                     ----------\n
          time_total:  %{time_total}\n
    使用格式文件发起访问
    curl -w '@format.txt' -o /dev/null -s -L 'http://voidchen.com'

耗时计算

  1. DNS耗时 = time_namelookup
  2. TCP建连耗时 = time_connect - time_namelookup
  3. SSL握手耗时 = time_appconnect - time_connect
  4. 服务器处理请求耗时 = time_starttransfer - time_pretransfer
  5. TTFB耗时 = time_starttransfer - time_appconnect
  6. 服务器传输耗时 = time_total - time_starttransfer
  7. 总耗时 = time_total

TODO 分析脚本

参考


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 nickchenyx@gmail.com

Title:curl 实战

Count:402

Author:nickChen

Created At:2022-10-14, 22:19:41

Updated At:2023-05-08, 23:27:10

Url:http://nickchenyx.github.io/2022/10/14/curl_usage/

Copyright: 'Attribution-non-commercial-shared in the same way 4.0' Reprint please keep the original link and author.