ubuntu中安装apache ab命令进行简单压力测试

前端之家收集整理的这篇文章主要介绍了ubuntu中安装apache ab命令进行简单压力测试前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.安裝ab命令

  1. sudo apt-get install apache2-utils

2.ab命令参数说明

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

3.运行 ab -n 100 -c 10 http://www.meetu.hk/ 对 http://www.meetu.hk/ 进行100次请求,10个并发请求压力测试结果。

  1. Server Software: lighttpd/1.4.20
  2. Server Hostname: www.meetu.hk
  3. Server Port: 80
  4. Document Path: /
  5. Document Length: 2095 bytes
  6. Concurrency Level: 10
  7. //整个测试持续的时间
  8. Time taken for tests: 3.303 seconds
  9. //完成的请求数量
  10. Complete requests: 100
  11. Failed requests: 0
  12. Write errors: 0
  13. Total transferred: 235200 bytes
  14. HTML transferred: 209500 bytes
  15. //平均每秒处理30个请求
  16. Requests per second: 30.27 [#/sec] (mean)
  17. //平均每个请求处理时间为330毫秒 注:这里将一次10个并发请求看成一个整体
  18. Time per request: 330.335 [ms] (mean)
  19. //平均每个并发请求处理 时间 为33毫秒
  20. Time per request: 33.034 [ms] (mean,across all concurrent requests)
  21. Transfer rate: 69.53 [Kbytes/sec] received
  22. Connection Times (ms)
  23. min mean[+/-sd] median max
  24. Connect: 51 170 35.9 178 230
  25. Processing: 60 153 64.5 121 263
  26. Waiting: 55 148 64.4 115 258
  27. Total: 235 322 59.9 299 437
  28. Percentage of the requests served within a certain time (ms)
  29. //在这100个请求中有50%在299毫秒内完成
  30. 50% 299
  31. //在这100个请求中有66%在312毫秒内完成
  32. 66% 312
  33. 75% 383
  34. 80% 412
  35. 90% 431
  36. 95% 432
  37. 98% 436
  38. 99% 437
  39. 100% 437 (longest request)

猜你在找的Ubuntu相关文章