黑白格子

  • 首页
  • 所有文章
  • 文章分类
  • 关于页面
  • 友链

  • 搜索
随笔 脚本 Shell MAC IE SSL iptables 网络 k8s docker ubuntu web 镜像 Nginx Linux Windows cloud-init

Linux下网站访问速率测试

发表于 2020-05-07 | 分类于 Linux | 0 | 阅读次数 269
1. curl命令加参数方法1:
curl -o /dev/null -s -w %{http_code}::%{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" https://www.baidu.com/

-o:把curl 返回的html、js 输出至回收站[ /dev/null]
-s:去掉所有状态
-w:按照后面的格式写出rt
--connect-timeout:指定tcp连接超时时间
-m:指定数据传输超时时间
http_code:状态码
time_namelookup:DNS 解析域名 www.baidu.com 的时间,单位为秒,如果测试的地址为IP,这里耗时即为0
time_connect:client 和 server 端建立 TCP 连接的时间
time_starttransfer:从 client 发出请求;到 web server 响应第一个字节的时间
time_total:client 发出请求;到 web server 发送回所有的相应数据的时间
speed_download:下载速度,单位 byte/s

image.png

2. curl命令加参数方法2:
time_namelookup —— 域名解析耗时
time_connect —— 建立到服务器的 TCP 连接所用的时间
time_appconnect —— 如SSL/SSH等建立连接或者完成三次握手时间
http_code —— 上次操作返回的响应码;
time_total —— 上次操作耗时,单位为秒;
time_connect —— TCP连接远程主机的耗时,单位为秒;
time_pretransfer —— 文件真正开始传输之前交互耗时,单位为秒,可能主要包括一些命令处理和协议分析的耗时;
time_redirect} —— 重定向耗时,单位微妙;
time_starttransfer —— 文件的第一个字节开始传输之前的耗时,单位为秒,包括time_pretransfer和服务器计算结果的时间;
size_download —— 下载的总字节数;
size_upload —— 上传的总字节数;
size_request —— 发送http请求的总字节数;
speed_download —— curl成功下载的平均下载速度;
speed_upload —— curl成功上传的平均上传速度;

shell> cat curl.format
time_namelookup:    %{time_namelookup}\n
time_connect:       %{time_connect}\n
time_appconnect:    %{time_appconnect}\n
time_pretransfer:   %{time_pretransfer}\n
time_redirect:      %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
time_total:         %{time_total}\n

shell> curl -so /dev/null -w @curl.format https://www.baidu.com
time_namelookup:    0.004029
time_connect:       0.014525
time_appconnect:    0.048664
time_pretransfer:   0.048708
time_redirect:      0.000000
time_starttransfer: 0.060849
time_total:         0.060921

image.png

3. Python封装curl后的httpstat工具
httpstat:

安装使用:
参考:
https://github.com/reorx/httpstat

文件方式:
wget https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py

pip方式:
pip install httpstat

image.png
image.png

  • 本文作者: 黑白格子
  • 本文链接: https://www.clhuang.cn/?p=5
  • 版权声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 4.0 许可协议。转载请注明出处!
# 随笔 # 脚本 # Shell # MAC # IE # SSL # iptables # 网络 # k8s # docker # ubuntu # web # 镜像 # Nginx # Linux # Windows # cloud-init
记一次cloud-init执行报错
Ubuntu 18.04 网卡配置
黑白格子

黑白格子

54 日志
11 分类
17 标签
Creative Commons
0%
© 2021 黑白格子
主题 - NexT.Mist
网站已稳定运行:
陕ICP备16020191号