“关于压力测试和并发的那些事儿”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
(未显示同一用户的8个中间版本)
第47行: 第47行:
 
可能就动不了了  
 
可能就动不了了  
 
ab -n 10000  -c 10000  http://192.168.88.173/index.html
 
ab -n 10000  -c 10000  http://192.168.88.173/index.html
 +
 +
eg
 +
# ab -n 1000  -c 1000  http://192.168.88.173/index.html
 +
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
 +
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
 +
Licensed to The Apache Software Foundation, http://www.apache.org/
 +
 +
Benchmarking 192.168.88.173 (be patient)
 +
Completed 100 requests
 +
Completed 200 requests
 +
Completed 300 requests
 +
Completed 400 requests
 +
Completed 500 requests
 +
Completed 600 requests
 +
Completed 700 requests
 +
Completed 800 requests
 +
Completed 900 requests
 +
Completed 1000 requests
 +
Finished 1000 requests
 +
 +
 +
Server Software:        Apache
 +
Server Hostname:        192.168.88.173
 +
Server Port:            80
 +
 +
Document Path:          /index.html
 +
Document Length:        196 bytes
 +
 +
Concurrency Level:      1000
 +
Time taken for tests:  0.404 seconds
 +
Complete requests:      1000
 +
Failed requests:        0
 +
Non-2xx responses:      1000
 +
Total transferred:      360000 bytes
 +
HTML transferred:      196000 bytes
 +
Requests per second:    2473.61 [#/sec] (mean)
 +
Time per request:      404.268 [ms] (mean)
 +
Time per request:      0.404 [ms] (mean, across all concurrent requests)
 +
Transfer rate:          869.63 [Kbytes/sec] received
 +
 +
Connection Times (ms)
 +
              min  mean[+/-sd] median  max
 +
Connect:        1  26  23.5    18      75
 +
Processing:    13  170 108.4    234    323
 +
Waiting:        1  170 108.5    234    323
 +
Total:        14  196 128.7    246    392
 +
 +
Percentage of the requests served within a certain time (ms)
 +
  50%    246
 +
  66%    279
 +
  75%    300
 +
  80%    312
 +
  90%    369
 +
  95%    380
 +
  98%    387
 +
  99%    389
 +
100%    392 (longest request)
 +
 +
 +
siege简单易用,其缺点在于统计结果过于粗糙。
 +
 +
如果想知道请求的平均时间、连接、处理、等待时间等信息,可以用apache自带的AB工具(Apache Benchmark)
 +
 +
参数很多,一般我们用 -c 和 -n 参数就可以了. 例如:
 +
 +
./ab -c 1000 -n 1000 http://127.0.0.1/index.php
 +
 +
输出的关键参数包括但不限于:
 +
 +
Requests per second: 122.12 [#/sec] (mean)
 +
//大家最关心的指标之一,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值
 +
Time per request: 8188.731 [ms] (mean)
 +
//大家最关心的指标之二,相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值
 +
Time per request: 8.189 [ms] (mean, across all concurrent requests)
 +
//每个请求实际运行时间的平均值
 +
Transfer rate: 162.30 [Kbytes/sec] received
 +
//平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
 +
 +
Connection Times (ms)
 +
min mean[+/-sd] median max // 最小值、平均数、中位数、最大值
 +
Connect: 4 646 1078.7 89 3291
 +
Processing: 165 992 493.1 938 4712
 +
Waiting: 118 934 480.6 882 4554
 +
Total: 813 1638 1338.9 1093 7785
 
   
 
   
 
  </pre>
 
  </pre>
 +
[https://www.jianshu.com/p/3afa6ecca808 ab压测]
 +
 +
[https://www.cnblogs.com/linjiqin/p/9058432.html 网站性能压力测试工具--apache ab使用详解]
 +
 +
[https://www.cnblogs.com/lawlietfans/p/6873306.html  如何使用siege测试服务器性能 ]
 +
 
===siege ===
 
===siege ===
 
<pre>
 
<pre>
 +
Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力。可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。siege可以从您选择的预置列表中请求随机的URL。所以siege可用于仿真用户请求负载,而ab则不能。但不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多。
  
 +
Sproxy做为一个代理侦听9001端口,可用于搜集正常访问的GET/POST请求、生成siege适用的Urls.txt文件格式。
  
 
可能得修改一下配置
 
可能得修改一下配置
第80行: 第172行:
  
  
 +
参数说明
 +
 +
url文件格式_GET
 +
server=172.17.19.80:80
 +
http://${server}/q?k1=v1&k2=v2
 +
 +
url文件格式_POST
 +
server=172.17.19.80:80
 +
http://${server}/q POST k1=v1&k2=v2
 +
 +
结果说明
 +
** SIEGE 2.72
 +
02
 +
** Preparing 300 concurrent users for battle.
 +
03
 +
The server is now under siege.. done.
 +
04
 +
 
 +
05
 +
Transactions:            30000 hits      #完成30000次处理
 +
06
 +
Availability:            100.00 %        #成功率
 +
07
 +
Elapsed time:            68.59 secs      #总共使用时间
 +
08
 +
Data transferred:        817.76 MB        #共数据传输 817.76 MB
 +
09
 +
Response time:            0.04 secs      #响应时间,显示网络连接的速度
 +
10
 +
Transaction rate:        437.38 trans/sec #平均每秒完成 437.38 次处理
 +
11
 +
Throughput:              11.92 MB/sec    #平均每秒传送数据
 +
12
 +
Concurrency:              17.53          #实际最高并发连接数
 +
13
 +
Successful transactions:  30000          #成功处理次数
 +
14
 +
Failed transactions:          0          #失败处理次数
 +
15
 +
Longest transaction:      3.12          #每次传输所花最长时间
 +
16
 +
Shortest transaction:      0.00          #每次传输所花最短时间
 
</pre>
 
</pre>
  
 
https://askubuntu.com/questions/932449/siege-cannot-perform-load-testing-for-more-than-255-tests
 
https://askubuntu.com/questions/932449/siege-cannot-perform-load-testing-for-more-than-255-tests
 +
 +
[https://www.jianshu.com/p/19b921511775 压力测试工具Siege有相关参数]
 +
 +
  
  
第88行: 第226行:
  
 
[https://www.vpser.net/opt/webserver-test.html  Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程]
 
[https://www.vpser.net/opt/webserver-test.html  Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程]
 +
 +
[http://www.ha97.com/4663.html (总结)Web性能压力测试工具之Siege详解]
  
 
===如果你是 windows .net  请用 ===
 
===如果你是 windows .net  请用 ===
第98行: 第238行:
  
 
== 参考==
 
== 参考==
 +
 +
Apache JMeter是Apache组织开发的基于Java的压力测试工具。用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域,比如接口测试等。
 +
[https://www.jianshu.com/p/fe82b953002c Jmeter学习记录1----入门]
 +
 
[https://segmentfault.com/q/1010000000588140  如何测试一个web网站的性能(并发数)?]
 
[https://segmentfault.com/q/1010000000588140  如何测试一个web网站的性能(并发数)?]
  

2021年5月4日 (二) 06:09的最新版本

start

首先是基本知识点

系统吞吐量(TPS)、用户并发量、性能测试概念和公式


这两个比较偏向web 测试

详情测试评估请见

并发承载

10W 活跃用户  访问4个页面  一次页面加3次接口

10w*4*4 =160W 

一般人睡觉8个小时 so 一天 24-8=16h
10W日活 * 4次访问数*每次4个接口或者页面 = 160W 
16h*60min*60s= 57 600 s
160w/57600=28QPS OR TPS

真实情况下
5 分钟内的活跃用户为1000
100*4*4=1600
1600/(5*6)=53QPS

反来说
如果一个系统的qps 100   一天能顶的访问量为 100*60*60*24=8 640 000 也就是864W 


ps
TPS:Transactions Per Second(每秒传输的事物处理个数)

 QPS(TPS):每秒钟 request/事务 数量,在互联网领域,指每秒响应请求数(指http请求)

常用的压力测试工具

ab

 ab  参数有时比较 搞笑
 10000 请求100并发
 ab -n  10000 -c  100 ip 

Usage: ab [options] [http[s]://]hostname[:port]/path
ab -n 100 -c 10 http://192.168.88.173/index.html


ab -n 1000  -c 1000  http://192.168.88.173/index.html

可能就动不了了 
ab -n 10000  -c 10000  http://192.168.88.173/index.html

eg 
# ab -n 1000  -c 1000  http://192.168.88.173/index.html
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.88.173 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache
Server Hostname:        192.168.88.173
Server Port:            80

Document Path:          /index.html
Document Length:        196 bytes

Concurrency Level:      1000
Time taken for tests:   0.404 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      360000 bytes
HTML transferred:       196000 bytes
Requests per second:    2473.61 [#/sec] (mean)
Time per request:       404.268 [ms] (mean)
Time per request:       0.404 [ms] (mean, across all concurrent requests)
Transfer rate:          869.63 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   26  23.5     18      75
Processing:    13  170 108.4    234     323
Waiting:        1  170 108.5    234     323
Total:         14  196 128.7    246     392

Percentage of the requests served within a certain time (ms)
  50%    246
  66%    279
  75%    300
  80%    312
  90%    369
  95%    380
  98%    387
  99%    389
 100%    392 (longest request)


siege简单易用,其缺点在于统计结果过于粗糙。

如果想知道请求的平均时间、连接、处理、等待时间等信息,可以用apache自带的AB工具(Apache Benchmark)

参数很多,一般我们用 -c 和 -n 参数就可以了. 例如:

./ab -c 1000 -n 1000 http://127.0.0.1/index.php

输出的关键参数包括但不限于:

Requests per second: 122.12 [#/sec] (mean)
//大家最关心的指标之一,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值
Time per request: 8188.731 [ms] (mean)
//大家最关心的指标之二,相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值
Time per request: 8.189 [ms] (mean, across all concurrent requests)
//每个请求实际运行时间的平均值
Transfer rate: 162.30 [Kbytes/sec] received
//平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题

Connection Times (ms)
min mean[+/-sd] median max // 最小值、平均数、中位数、最大值
Connect: 4 646 1078.7 89 3291
Processing: 165 992 493.1 938 4712
Waiting: 118 934 480.6 882 4554
Total: 813 1638 1338.9 1093 7785
 
 

ab压测

网站性能压力测试工具--apache ab使用详解

如何使用siege测试服务器性能

siege

Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力。可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。siege可以从您选择的预置列表中请求随机的URL。所以siege可用于仿真用户请求负载,而ab则不能。但不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多。

Sproxy做为一个代理侦听9001端口,可用于搜集正常访问的GET/POST请求、生成siege适用的Urls.txt文件格式。

可能得修改一下配置
 siege -c  2000  -t 60s http:192.168.88.173

================================================================
WARNING: The number of users is capped at 255.  To increase this
         limit, search your .siegerc file for 'limit' and change
         its value. Make sure you read the instructions there...
================================================================

vim  .siege/siege.conf

# ex: limit = 1023 (default is 255)                                                                                                                                          
#                                                                                                                                                                            
limit = 2559





 100并发  30s
 siege -c  100 -t 30s http:ip 
 
 wrk 可以lua脚本 
 4个线程
 wrk -c 100 -d 30s -t 4 ip 


参数说明

url文件格式_GET
	server=172.17.19.80:80
	http://${server}/q?k1=v1&k2=v2

url文件格式_POST
	server=172.17.19.80:80
	http://${server}/q POST k1=v1&k2=v2

结果说明
** SIEGE 2.72
02
	** Preparing 300 concurrent users for battle.
03
	The server is now under siege.. done.
04
	  
05
	Transactions:             30000 hits      #完成30000次处理
06
	Availability:            100.00 %         #成功率
07
	Elapsed time:             68.59 secs      #总共使用时间
08
	Data transferred:        817.76 MB        #共数据传输 817.76 MB
09
	Response time:             0.04 secs      #响应时间,显示网络连接的速度
10
	Transaction rate:        437.38 trans/sec #平均每秒完成 437.38 次处理
11
	Throughput:               11.92 MB/sec    #平均每秒传送数据
12
	Concurrency:              17.53           #实际最高并发连接数
13
	Successful transactions:  30000           #成功处理次数
14
	Failed transactions:          0           #失败处理次数
15
	Longest transaction:       3.12           #每次传输所花最长时间
16
	Shortest transaction:      0.00           #每次传输所花最短时间

https://askubuntu.com/questions/932449/siege-cannot-perform-load-testing-for-more-than-255-tests

压力测试工具Siege有相关参数



介绍几款Web服务器性能压力测试工具ApacheBench(ab) Siege详解

Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程

(总结)Web性能压力测试工具之Siege详解

如果你是 windows .net 请用

如何测试一个网站的性能(并发数)

ASP.NET压力测试

如何对Asp.Net网站做并发测试?

参考

Apache JMeter是Apache组织开发的基于Java的压力测试工具。用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域,比如接口测试等。 Jmeter学习记录1----入门

如何测试一个web网站的性能(并发数)?

早知道早幸福——从压测工具谈并发、压力、吞吐量

如何估算网站日承受最大访问PV