centos安裝ab壓力測試

方式一:php

yum install apr-util

mkdir /ab
cd /ab

yum -y install yum-utils
yumdownloader httpd
rpm2cpio httpd-*.rpm | cpio -idmv


cp /ab/usr/bin/ab /usr/bin
rm -fr /ab

方式二:html

yum install httpd-tools

運行 前端

ab -c 100 -n 10000 http://127.0.0.1/index.php nginx

-c 100 即:每次併發100個
-n 10000 即: 共發送10000個請求
bash

模擬併發請求100次,總共請求10000次

內容解釋
Server Software:        nginx/1.10.2 (服務器軟件名稱及版本信息)
Server Hostname:        192.168.1.106(服務器主機名)
Server Port:            80 (服務器端口)
Document Path:          /index1.html. (供測試的URL路徑)
Document Length:        3721 bytes (供測試的URL返回的文檔大小)
Concurrency Level:      1000 (併發數)
Time taken for tests:   2.327 seconds (壓力測試消耗的總時間)
Complete requests:      5000 (的總次數)
Failed requests:        688 (失敗的請求數)
Write errors:           0 (網絡鏈接寫入錯誤數)
Total transferred:      17402975 bytes (傳輸的總數據量)
HTML transferred:       16275725 bytes (HTML文檔的總數據量)
Requests per second:    2148.98 [#/sec] (mean) (平均每秒的請求數) 這個是很是重要的參數數值,服務器的吞吐量 
Time per request:       465.338 [ms] (mean) (全部併發用戶(這裏是1000)都請求一次的平均時間)
Time  request:       0.247 [ms] (mean, across all concurrent requests) (單個用戶請求一次的平均時間)
Transfer rate:          7304.41 [Kbytes/sec] received 每秒獲取的數據長度 (傳輸速率,單位:KB/s)
...
Percentage of the requests served within a certain time (ms)
  50%    347  ## 50%的請求在347ms內返回 
  66%    401  ## 60%的請求在401ms內返回 
  75%    431
  80%    516
  90%    600
  95%    846
  98%   1571
  99%   1593
 100%   1619 (longest request)服務器

注意事項

  • 測試機與被測試機要分開
  • 不要對線上的服務器作壓力測試
  • 觀察測試工具ab所在機器,以及被測試的前端機的CPU、內存、網絡等都不超過最高限度的75%
相關文章
相關標籤/搜索