本文共 4413 字,大约阅读时间需要 14 分钟。
siege压力测试,siege会将接口进行模拟并发,返回每秒的并发数!
一、siege的安装
下载:wget 一、siege的安装下载:wget 解压: tar -zxvf siege-latest.tar.gzcd siege-..*./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/sslmkdir -p /usr/local/siege/etcmkdir -p /usr/local/siege/varmakemake install查看配置文件/usr/local/siege/bin/siege -C
二、siege的使用
举例说明:50个用户(每次并发量)重复100次 共产生 50*100 个请求/usr/local/siege/bin/siege -c 50 -r 100 www.baidu.com50个用户 重复100次 发送GET参数/usr/local/siege/bin/siege -c 50 -r 100 http://www.baidu.com/s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=6050个用户 重复100次 发送POST参数 (注意引号)/usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST name=zhangsan"50个用户 重复100次 发送POST参数(从文件中读取)/usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST < /root/ab_test/post.xml"另外还有挺多参数详情请man 或 siege -hsiege报表解析,请man查看,暂略(有点累了,不想写了。。。。。)。Transactions: 10 hits :服务器接收的请求数Availability: 100.00 % :有效情况的比例Elapsed time: 1.06 secs : 测试所用的时间Data transferred: 0.04 MB :每个模拟用户的数据传输量Response time: 0.03 secs :响应每个模拟用户请求的平均时间Transaction rate: 9.43 trans/sec :服务器每秒处理事务的平均数Throughput: 0.04 MB/sec :服务器每秒跟所有模拟用户的数据传输量Concurrency: 0.25 :每秒的模拟连接Successful transactions: 10 :处理成功的事务数(code<400)Failed transactions: 0 : 处理失败的事务数(code>400)Longest transaction: 0.04 :最长的事务处理时间Shortest transaction: 0.02 :最短的事务处理时间
siege -c 200 -r 10 -f example.url
-c是并发量,-r是重复次数。 url文件就是一个文本,每行都是一个url,它会从里面随机访问的。example.url内容:
结果说明
Lifting the server siege… done.Transactions: 3419263 hits //完成419263次处理Availability: 100.00 % //100.00 % 成功率Elapsed time: 5999.69 secs //总共用时Data transferred: 84273.91 MB //共数据传输84273.91 MBResponse time: 0.37 secs //相应用时1.65秒:显示网络连接的速度Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次处理:表示服务器后Throughput: 14.05 MB/sec //平均每秒传送数据Concurrency: 213.42 //实际最高并发数Successful transactions: 2564081 //成功处理次数Failed transactions: 11 //失败处理次数Longest transaction: 29.04 //每次传输所花最长时间Shortest transaction: 0.00 //每次传输所花最短时间解压: tar -zxvf siege-latest.tar.gzcd siege-..*./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/sslmkdir -p /usr/local/siege/etcmkdir -p /usr/local/siege/varmakemake install查看配置文件/usr/local/siege/bin/siege -C
二、siege的使用
举例说明:50个用户(每次并发量)重复100次 共产生 50*100 个请求/usr/local/siege/bin/siege -c 50 -r 100 www.baidu.com50个用户 重复100次 发送GET参数/usr/local/siege/bin/siege -c 50 -r 100 http://www.baidu.com/s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=6050个用户 重复100次 发送POST参数 (注意引号)/usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST name=zhangsan"50个用户 重复100次 发送POST参数(从文件中读取)/usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST < /root/ab_test/post.xml"另外还有挺多参数详情请man 或 siege -hsiege报表解析,请man查看,暂略(有点累了,不想写了。。。。。)。Transactions: 10 hits :服务器接收的请求数Availability: 100.00 % :有效情况的比例Elapsed time: 1.06 secs : 测试所用的时间Data transferred: 0.04 MB :每个模拟用户的数据传输量Response time: 0.03 secs :响应每个模拟用户请求的平均时间Transaction rate: 9.43 trans/sec :服务器每秒处理事务的平均数Throughput: 0.04 MB/sec :服务器每秒跟所有模拟用户的数据传输量Concurrency: 0.25 :每秒的模拟连接Successful transactions: 10 :处理成功的事务数(code<400)Failed transactions: 0 : 处理失败的事务数(code>400)Longest transaction: 0.04 :最长的事务处理时间Shortest transaction: 0.02 :最短的事务处理时间
siege -c 200 -r 10 -f example.url
-c是并发量,-r是重复次数。 url文件就是一个文本,每行都是一个url,它会从里面随机访问的。example.url内容:
结果说明
Lifting the server siege… done.Transactions: 3419263 hits //完成419263次处理Availability: 100.00 % //100.00 % 成功率Elapsed time: 5999.69 secs //总共用时Data transferred: 84273.91 MB //共数据传输84273.91 MBResponse time: 0.37 secs //相应用时1.65秒:显示网络连接的速度Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次处理:表示服务器后Throughput: 14.05 MB/sec //平均每秒传送数据Concurrency: 213.42 //实际最高并发数Successful transactions: 2564081 //成功处理次数Failed transactions: 11 //失败处理次数Longest transaction: 29.04 //每次传输所花最长时间Shortest transaction: 0.00 //每次传输所花最短时间转载于:https://blog.51cto.com/kangjunfei/2091575