关于压力测试和并发的那些事儿
跳到导航
跳到搜索
目录
start
首先是基本知识点
这两个比较偏向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
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
介绍几款Web服务器性能压力测试工具ApacheBench(ab) Siege详解
Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程