前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux ab 压力测试

Linux ab 压力测试

作者头像
全栈程序员站长
发布2022-07-11 14:58:13
3.4K0
发布2022-07-11 14:58:13
举报

大家好,又见面了,我是全栈君。

ab 是 Apache 附带的接口压力测试功能,非常简单易用。在测试服务端程序自身运行时长和跨区测试接口反馈时长时非常有用。

下载

CentOS

代码语言:javascript
复制
$ sudo yum install -y httpd

Ubuntu

代码语言:javascript
复制
$ sudo apt install -y apache2-utils

使用

代码语言:javascript
复制
$ ab -c 10 -n 100 http://ip-api.com/json

参数

  • -c: 表示并发数
  • -n: 表示请求总数

结果

代码语言:javascript
复制
> $ ab -c 10 -n 100 http://ip-api.com/json
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking ip-api.com (be patient).....done


Server Software:
Server Hostname:        ip-api.com
Server Port:            80

Document Path:          /json
Document Length:        306 bytes

Concurrency Level:      10
Time taken for tests:   6.184 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      46200 bytes
HTML transferred:       30600 bytes
Requests per second:    16.17 [#/sec] (mean)
Time per request:       618.369 [ms] (mean)
Time per request:       61.837 [ms] (mean, across all concurrent requests)
Transfer rate:          7.30 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    3   1.1      3       6
Processing:   528  572  58.4    550     889
Waiting:      528  571  58.7    549     888
Total:        531  575  58.3    552     891

Percentage of the requests served within a certain time (ms)
  50%    552
  66%    565
  75%    574
  80%    600
  90%    635
  95%    656
  98%    890
  99%    891
 100%    891 (longest request)

结果详解

代码语言:javascript
复制
Server Software:        web服务器软件及版本
Server Hostname:        请求的地址
Server Port:            请求的端口

Document Path:          请求的页面路径
Document Length:        页面大小

Concurrency Level:      并发数
Time taken for tests:   测试总共花费的时间
Complete requests:      完成的请求数
Failed requests:        失败的请求数
Write errors:           写入错误
Total transferred:      总共传输字节数,包含http的头信息等
HTML transferred:       html字节数,实际的页面传递字节数
Requests per second:    每秒处理的请求数,服务器的吞吐量(重要)
Time per request:       平均数,用户平均请求等待时间
Time per request:       服务器平均处理时间
Transfer rate:          平均传输速率(每秒收到的速率)

Time per request 是我们测试接口时长时非常关键的字段。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/111840.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年2月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 下载
  • 使用
相关产品与服务
测试服务
测试服务 WeTest 包括标准兼容测试、专家兼容测试、手游安全测试、远程调试等多款产品,服务于海量腾讯精品游戏,涵盖兼容测试、压力测试、性能测试、安全测试、远程调试等多个方向,立体化安全防护体系,保卫您的信息安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档