使用ab在本机进行nginx性能测试

压力测试工具Ab简介

Apache
安装包中自带的压力测试工具 Apache Benchmark(简称ab) 简单易用,这里就采用 ab作为压力测试工具了。

1.独立安装

ab运行需要依赖apr-util包,安装命令为: 

1yum install apr-util

安装依赖 yum-utils中的yumdownload 工具

如果没有找到 yumdownload 命令可以

1yum install yum-utils

安装完成后执行以下指令

1cd /opt
2mkdir abtmp
3cd abtmp
4yum install yum-utils.noarch
5yumdownloader httpd-tools*
6rpm2cpio httpd-*.rpm | cpio -idmv

解开后就能得到独立的 ab可执行文件了。

操作完成后 将会产生一个 usr 目录 ab文件就在这个usr 目录中


2.参数详解


-n requests     Number of requests to perform
//在测试会话中所执行的请求个数。默认时,仅执行一个请求
-c concurrency Number of multiple requests to make
//一次产生的请求个数。默认是一次一个。

在终端输入:
ab -c 1000 -n 10000 http://localhost:8888/index.html



Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.2.0
Server Hostname:        localhost
Server Port:            8888

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

Concurrency Level:      1000
Time taken for tests:   2.086 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      3863040 bytes
HTML transferred:       1750440 bytes
Requests per second:    4794.88 [#/sec] (mean)
Time per request:       208.556 [ms] (mean)
Time per request:       0.209 [ms] (mean, across all concurrent requests)
Transfer rate:          1808.87 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   63 203.3     10    1023
Processing:     9   31  29.2     23     646
Waiting:        5   26  26.4     19     643
Total:         19   94 215.2     33    1271

Percentage of the requests served within a certain time (ms)
  50%     33
  66%     50
  75%     61
  80%     67
  90%    149
  95%    162
  98%   1041
  99%   1075
 100%   1271 (longest request)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值