Linux ab 压力测试

Linux ab 压力测试

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

 

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

下载

CentOS

$ sudo yum install -y httpd

Ubuntu

$ sudo apt install -y apache2-utils

 

使用

$ ab -c 10 -n 100 http://ip-api.com/json

参数

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

结果

> $ 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)

结果详解

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.net/111840.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • long long转string代码

    long long转string代码stringlltoString(longlongtimestamp){stringresult;ostringstreamss;ss<<timestamp;istringstreamis(ss.str());is>>result;returnresult;}包含头文件:#include…

    2022年5月14日
    39
  • 数据权限设计(转载)

    数据权限设计(转载)一、前言几乎在任何一个系统中,都离不开权限的设计,权限设计=功能权限+数据权限,而功能权限,在业界常常是基于RBAC(Role-BasedAccessControl)的一套方案。而数据权限,则根据不同的业务场景,则权限却不尽相同,应该根据具体的场景巧妙设计;且必须在项目开始时进行设计,不像功能权限一样,在项目结束的时候在追加。注:更细还可以加入字段权限1.1权限…

    2022年7月16日
    14
  • goland 2021.05 激活码【在线破解激活】

    goland 2021.05 激活码【在线破解激活】,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月17日
    65
  • MT4下载怎么下?「建议收藏」

    MT4下载怎么下?「建议收藏」在哪里可以下载到mt4了?个人装了一些像应用宝这类的搜索软件,里面找不到地方下载MT4这个应用软件,怎么样,实际上到百度一搜索就能找到。当输入MT4的时候,会看到下拉框有这么多选择,只需选MT4安卓手机版输入便可`mt4download.cn`搜索出来肯定有很多下载链接,怎样选,正常选第一个搜索主页,【正版】MT4软件【免费下载】来自官网或正规下载网站,切记不要到那类广告网站,会给你电脑安装很多垃圾软件,使系统变得非常慢。点进这个链接后,你就能看到MetaTrader4广受欢迎的软件,根据你手机的操作系

    2022年8月15日
    11
  • statickeyword于C和C++用法

    statickeyword于C和C++用法

    2022年1月14日
    57
  • python一维插值scipy.interpolate.interp1d

    python一维插值scipy.interpolate.interp1dSciPy的interpolate模块提供了许多对数据进行插值运算的函数,范围涵盖简单的一维插值到复杂多维插值求解。当样本数据变化归因于一个独立的变量时,就使用一维插值;反之样本数据归因于多个独立变量时,使用多维插值。classscipy.interpolate.interp1d(x,y,kind=’linear’,axis=-1,copy=True,bounds_…

    2022年6月8日
    100

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号