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

来源:互联网 发布:c php des加密解密 编辑:程序博客网 时间:2024/06/05 18:23
压力测试工具Ab简介

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

1.独立安装

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

1yum installapr-util

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

如果没有找到 yumdownload 命令可以

1yum installyum-utils

安装完成后执行以下指令

1cd /opt
2mkdir abtmp
3cd abtmp
4yum installyum-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