我们一般会使用Apache自带的ab来对项目进行压力测试,看项目的执行情况如何.

我们可以使用 ab -v 来查看ab的详细参数使用方法.

  1. [root@node234 bin]# ./ab -v
  2. ab: option requires an argument -- v
  3. ./ab: wrong number of arguments
  4. Usage: ./ab [options] [http[s]://]hostname[:port]/path
  5. Options are:
  6. -n requests     Number of requests to perform
  7. -c concurrency  Number of multiple requests to make
  8. -t timelimit    Seconds to max. wait for responses
  9. -b windowsize   Size of TCP send/receive buffer, in bytes
  10. -p postfile     File containing data to POST. Remember also to set -T
  11. -u putfile      File containing data to PUT. Remember also to set -T
  12. -T content-type Content-type header for POSTing, eg.
  13. 'application/x-www-form-urlencoded'
  14. Default is 'text/plain'
  15. -v verbosity    How much troubleshooting info to print
  16. -w              Print out results in HTML tables
  17. -i              Use HEAD instead of GET
  18. -x attributes   String to insert as table attributes
  19. -y attributes   String to insert as tr attributes
  20. -z attributes   String to insert as td or th attributes
  21. -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
  22. -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
  23. Inserted after all normal header lines. (repeatable)
  24. -A attribute    Add Basic WWW Authentication, the attributes
  25. are a colon separated username and password.
  26. -P attribute    Add Basic Proxy Authentication, the attributes
  27. are a colon separated username and password.
  28. -X proxy:port   Proxyserver and port number to use
  29. -V              Print version number and exit
  30. -k              Use HTTP KeepAlive feature
  31. -d              Do not show percentiles served table.
  32. -S              Do not show confidence estimators and warnings.
  33. -g filename     Output collected data to gnuplot format file.
  34. -e filename     Output CSV file with percentages served
  35. -r              Don't exit on socket receive errors.
  36. -h              Display usage information (this message)
  37. -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
  38. -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)

要进行压力测试可以执行以下命令,可以修改相应的参数:

ab -n1000 -c10 http://e60.chenwd.xxx.com/carindex.php

Apache常用参数说明:

-n: 标识请求的总数.
-c: 标识请求的总用户 (如果请求的总数是1000,请求的总用户是10,那么平均每个用户执行100次请求)
-t: 请求的超时时间, 单位是秒.

执行结果:

  1. [root@node234 bin]# ./ab -n1000 -c10 http://e60.chenwd.xxx/carindex.php
  2. This is ApacheBench, Version 2.3 <$Revision: 655654 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking e60.chenwd.dev.eebaobao.com (be patient)
  6. Completed 100 requests
  7. Completed 200 requests
  8. Completed 300 requests
  9. Completed 400 requests
  10. Completed 500 requests
  11. Completed 600 requests
  12. Completed 700 requests
  13. Completed 800 requests
  14. Completed 900 requests
  15. Completed 1000 requests
  16. Finished 1000 requests
  17. Server Software:        nginx/0.9.4
  18. Server Hostname:        e60.xxx.com
  19. Server Port:            80
  20. Document Path:          /carindex.php
  21. Document Length:        5722 bytes
  22. Concurrency Level:      10
  23. Time taken for tests:   19.445 seconds
  24. Complete requests:      1000
  25. Failed requests:        0
  26. Write errors:           0
  27. Total transferred:      5990000 bytes
  28. HTML transferred:       5722000 bytes
  29. Requests per second:    51.43 [#/sec] (mean)
  30. Time per request:       194.446 [ms] (mean)
  31. Time per request:       19.445 [ms] (mean, across all concurrent requests)
  32. Transfer rate:          300.84 [Kbytes/sec] received
  33. Connection Times (ms)
  34. min  mean[+/-sd] median   max
  35. Connect:       12   60  19.8     58     205
  36. Processing:    47  133  32.9    126     298
  37. Waiting:       22   75  27.8     68     219
  38. Total:        112  193  36.8    183     374
  39. Percentage of the requests served within a certain time (ms)
  40. 50%    183
  41. 66%    195
  42. 75%    204
  43. 80%    214
  44. 90%    249
  45. 95%    270
  46. 98%    293
  47. 99%    304
  48. 100%    374 (longest request)

执行结果说明:
Server Software: 测试服务器的Web服务器软件名字
Server Hostname: 请求的域名
Server Port: 测试的访问端口
Document Path: 请求URL的绝问文件路径
Document Length: 表示HTTP相应的正文的长度
Concurrency Level: 标识并发的用户数(-c属性来设置)
Time taken for tests: 执行完所有的请求所花费的时间
Complete requests: 表示测试的总请求数
Failed requests: 失败的请求
Total transferred: 表示所有请求的响应数据的总和,包含头信息和正文长度.
HTML transferred: 表示所有请求中响应数据的正文长度 (不包含头信息的长度)
Requests per second: 这个就是我们要的吞吐率,表示每秒处理的请求数
Time per request: 表示每个用户平均等待的时间. 等于 Time taken for tests / (Complete requests / Concurrency Level)
Time per request:(mean, across all concurrent requests) 服务器平均请求处理的时间. 正是吞详细地址的倒数,为:Time per request / Concurrency Level 每个请求花费了多少秒
Transfer rate: 这些请求在单位内,从服务器获取的数据长度. 等于: Total transferred / Time taken for tests
Percentage of the requests served within a certain time (ms): 这部分数据用于描述每个请求处理时间的分页情况,百分之五十不超过183毫秒,. 百分之九十不超过249毫秒,百分百不超过374毫秒.

使用Apache ab进行压力测试(参数说明)的更多相关文章

  1. Apache ab参数--压力测试

    Apache附带的ab,它非常容易使用,ab可以直接在Web服务器本地发起测试请求.这至关重要,因为我们希望测试的服务器的处理时间,而不包含数据的网络传输时间以及用户PC本地的计算时间. 需要清楚的是 ...

  2. Apache自带压力测试工具ab用法简介

    ab命令原理 ab命令会创建很多的并发访问线程,模拟多个访问者同时对某一URL进行访问.它的测试目标是基于URL的,因此,既可以用来测试Apache的负载压力,也可以测试nginx.lighthttp ...

  3. PHP性能:序——谈ab(Apache Bench)压力测试工具

    PHP性能:序——谈ab(Apache Bench)压力测试工具 ab(Apache  Bench)是啥? ab是Apache自带的一个压力测试软件,可以通过ab命令和选项对某个URL进行压力测试.a ...

  4. 转:PHP性能:序——谈ab(Apache Bench)压力测试工具

    PHP性能:序——谈ab(Apache Bench)压力测试工具 ab(Apache  Bench)是啥? ab是Apache自带的一个压力测试软件,可以通过ab命令和选项对某个URL进行压力测试.a ...

  5. 开源的类似于Apache ab的压力测试命令行工具SuperBenchmarker

    SuperBenchmarker 是ㄧ个开源的类似于Apache ab的压力测试命令行工具.可以在 .NET 4.52+ 或者 .NET Core 2.0+ 平台上运行. 可支持Get.Post.Pu ...

  6. 使用Apache Benchmark做压力测试遇上的5个常见问题

    这一篇文章主要记录我在使用Apache Benchmark(一下检测ab)做网站压力测试的过程中,遇到的一些问题以及解决办法,方便日后使用. 这一篇文章主要记录我在使用Apache Benchmark ...

  7. kubernetes:基于ab的压力测试

    基于ab的压力测试 # cat apache-test.yaml ################################################################### ...

  8. 使用Apache的ab进行压力测试

    概述 ab是apache自带的压力测试工具,当安装完apache的时候,就可以在bin下面找到ab然后进行apache 负载压力测试. 后台测试开发中,常用的压力测试服务,php一般选择xampp,下 ...

  9. Apache自带压力测试工具----linux环境中ab命令简介及结果分析

    ab(apache bench)是apache下的一个工具,主要用于对web站点做压力测试, 基础用法: 其中-c选项为一次发送的请求数量,及并发量.-n选项为请求次数. 实验测试: [dev@web ...

随机推荐

  1. 【redmine】密码忘了后重新设置

    有段时间没有使用,忘记了原来的密码,搜索网上有一篇文章,不过版本比较老,和现在文件位置不一样,参考后成功重置了密码,感谢原作者. 原文内第一步一般是不需要的.主要是用ruby命令修改数据库内容. 进入 ...

  2. 误删dpkg的/var/lib/dpkg/info文件夹的解决办法 zhuan

         今天安装软件时时,出现这样的错误提示:E: Sub-process /usr/bin/dpkg returned an error code (1)   上网查解决方案,被网上误导,一不小心 ...

  3. UNIX环境高级编程笔记之标准I/O库

    一.总结 文件I/O一章讲了不带缓冲的I/O,本章讲的是带缓冲的I/O.不带缓冲针对的是内核的系统调用,而带缓冲针对的是用户空间的标准库函数,是基于带缓冲的I/O实现的.不带缓冲的I/O通过文件描述符 ...

  4. sql server还原数据库bak文件

    RESTORE DATABASE CCC FROM DISK = 'AAA.bak' with replace,  MOVE 'BBB' TO 'C:\Program Files\Microsoft ...

  5. Ubuntu下PHP的扩展

    Ubuntu版本:14.04 1. 下载php-5.5.10.tar.bz2,并解压. 2.  终端进入解压后的目录php-5.5.10,运行configure.(输入命令./configure) 3 ...

  6. HIVE: Transform应用实例

    数据文件内容 steven:100;steven:90;steven:99^567^22 ray:90;ray:98^456^30 Tom:81^222^33 期望最终放到数据库的数据格式如下: st ...

  7. CM: 使用gerrit,提交代码到CM

    1. Make sure your local git username matches with your Gerrit username, Gerrit username needs to be ...

  8. install keepalived on RedHat/CentOS to provide IP failover for web cluster

    Contents [hide]  1 Introduction 2 Our Sample Setup 3 Install Keepalived 4 Install Kernel Headers 5 C ...

  9. .NET 产品版权保护方案 (.NET源码加密保护) (转载)

    说 明:你希望自己用.net辛辛苦苦做出来的软件被人轻易破解吗?你希望自己花了大量人力物力用.net开发出来的产品被竞争对手轻易获取核心代码吗?这是 一篇比较详尽地介绍如何保护自己的.net源代码的文 ...

  10. android程序---->android多线程下载(一)

    多线程下载是加快下载速度的一种方式,通过开启多个线程去执行一个任务,可以使任务的执行速度变快.多线程的任务下载时常都会使用得到断点续传下载,就是我们在一次下载未结束时退出下载,第二次下载时会接着第一次 ...