雲server 性能測試web壓力測試

前言:現在,雲server主流。它已成爲許多中小型企業的首選server,可是雲server它是一個虛擬機。因此性能是一個大問題,從這裏開始介紹雲server性能測試,雲webserver壓力測試。php

Linux下常常使用的四款Webserver壓力測試工具(http_load、webbench、ab、siege),這裏採用apache自帶的ab工具來測試。html

1,開始安裝apache

前期準備:
yum install gcc* -y
yum install libtool* -ylinux

1.1,去官網下載

apache,http://httpd.apache.org/download.cgi#apache24
下載軟件包是:httpd-2.4.12.tar.gz web

解壓tar -zxvf httpd-2.2.6.tar.gz,完畢以後,會在當前文件夾出現一個httpd-2.2.6文件夾,而後順序運行例如如下命令更名:apache

tar -zxvf httpd-2.2.6.tar.gz
mv httpd-2.2.6 apache
cd apache

設置安裝參數,命令例如如下:
./configure –prefix=/usr/local/apache2 –enable-module=so –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util瀏覽器

[root@bwebhttpd-2.4.12]# ./configure --prefix=/usr/local/apache2 --enable-module=so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
[root@bwebhttpd-2.4.12]#

<版權所有,文章贊成轉載,但必須以連接方式註明源地址,不然追究法律責任!>
原博客地址: http://blog.csdn.net/mchdba/article/details/46381741
原做者:黃杉 (mchdba)
報錯APR…問題ruby


1.2 解決apr not found問題

http://apr.apache.org/download.cgi下載
wget http://archive.apache.org/dist/apr/apr-1.4.6.tar.gz。而後源代碼安裝markdown

[root@bwebdata]# cd apr-1.4.6
[root@bwebapr-1.4.6]# ./configure --prefix=/usr/local/apr
[root@bwebapr-1.4.6]# make
[root@bwebapr-1.4.6]# make install 


1.3.解決APR-util not found問題

需要安裝apr-util組件:app

[root@bwebdata]# wget http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz
[root@bwebdata]# tar -xvf apr-util-1.5.4.tar.gz 
[root@bwebdata]# cd apr-util-1.5.4
[root@bwebapr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@bwebapr-util-1.5.4]# make
[root@bwebapr-util-1.5.4]# make install

或者 yum install -y apr-util*dom

1.4 configure: error: pcre-config for libpcre not found問題

../configure加入了–with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util仍提示 configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/的錯誤

查看下是否有pcre參數
[root@bwebhttpd-2.4.12]# ./configure -help | grep pcre
–with-pcre=PATH Use external PCRE library
[root@bwebhttpd-2.4.12]#

沒有這個參數。因此需要又一次下載安裝:
下載pcre,下載地址一:http://sourceforge.net/projects/pcre 下載地址二:http://ftp.exim.llorien.org/pcre/

[root@bwebdata]# wget http://ftp.exim.llorien.org/pcre/pcre-8.36.tar.gz
--這裏因爲下載失敗。因此又一次去csdn資源庫下載了pcre的zip包
[root@bwebdata]# unzip pcre-8.36.zip 
[root@bwebdata]# cd pcre-8.36
[root@bwebpcre-8.36]# ./configure --prefix=/usr/local/pcre
[root@bwebpcre-8.36]# make
[root@bwebpcre-8.36]# make install 

或者 yum安裝也可以:

[root@bwebhttpd-2.4.12]# yum install -y pcre*


必要的組件安裝完了。咱們可以繼續源代碼編譯apache了

2 最後編譯安裝apache

[root@bwebhttpd-2.4.12]# ./configure --prefix=/usr/local/apache2 --enable-module=so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-included-apr
[root@bwebhttpd-2.4.12]# make 
[root@bwebhttpd-2.4.12]# make install

啓動apache
/usr/local/apache2/bin/apachectl start

[root@bwebhttpd-2.4.12]# /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.16.1.4. Set the 'ServerName' directive globally to suppress this message
[root@bwebhttpd-2.4.12]# 

查看下:
在瀏覽器中輸入地址:http://172.16.1.4/,會顯演示樣例如如下信息:
It works!

apache安裝完畢後ab命令存放在apache安裝文件夾的bin文件夾下。例如如下:

[root@bwebhttpd-2.4.12]# ll /usr/local/apache2/bin
total 2308
-rwxr-xr-x. 1 root root 80799 Jun 4 12:48 ab -rwxr-xr-x. 1 root root 3438 Jun 4 12:43 apachectl -rwxr-xr-x. 1 root root 23515 Jun 4 12:43 apxs -rwxr-xr-x. 1 root root 12277 Jun 4 12:48 checkgid -rwxr-xr-x. 1 root root 8925 Jun 4 12:43 dbmmanage -rw-r--r--. 1 root root 1073 Jun 4 12:43 envvars -rw-r--r--. 1 root root 1073 Jun 4 12:43 envvars-std -rwxr-xr-x. 1 root root 20200 Jun 4 12:48 fcgistarter -rwxr-xr-x. 1 root root 66594 Jun 4 12:48 htcacheclean -rwxr-xr-x. 1 root root 40674 Jun 4 12:48 htdbm -rwxr-xr-x. 1 root root 22263 Jun 4 12:48 htdigest -rwxr-xr-x. 1 root root 41346 Jun 4 12:48 htpasswd -rwxr-xr-x. 1 root root 1933978 Jun 4 12:48 httpd -rwxr-xr-x. 1 root root 19488 Jun 4 12:48 httxt2dbm -rwxr-xr-x. 1 root root 21908 Jun 4 12:48 logresolve -rwxr-xr-x. 1 root root 34593 Jun 4 12:48 rotatelogs [root@bwebhttpd-2.4.12]#

/usr/local/apache2/bin/ab -c 1000 -n 1000 http://127.0.0.1/phpinfo.php


3,ab壓測結果例如如下:

3.1 微軟雲壓測

ab壓測結果例如如下:

[root@bwebhttpd-2.4.12]# /usr/local/apache2/bin/ab -c 1000 -n 1000 http://127.0.0.1/phpinfo.php
This is ApacheBench, Version 2.3 <$Revision: 1638069 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.12
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /phpinfo.php
Document Length:        209 bytes

Concurrency Level:      1000
Time taken for tests:   0.676 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      387000 bytes
HTML transferred:       209000 bytes
Requests per second:    1478.80 [#/sec] (mean)
Time per request:       676.224 [ms] (mean)
Time per request:       0.676 [ms] (mean, across all concurrent requests)
Transfer rate:          558.88 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4   28  20.1     14      65
Processing:     4   90 155.1     18     608
Waiting:        3   87 156.2     13     608
Total:         16  118 169.9     29     665

Percentage of the requests served within a certain time (ms)
  50%     29
  66%     52
  75%    266
  80%    267
  90%    270
  95%    662
  98%    663
  99%    663
 100%    665 (longest request)
[root@bwebhttpd-2.4.12]

下面是加帶了-k參數。表示不釋放鏈接:
ab -k -c 1000 -n 1000 http://127.0.0.1/phpinfo.php

[root@bwebhttpd-2.4.12]# /usr/local/apache2/bin/ab -k -c 1000 -n 1000 http://127.0.0.1/phpinfo.php
This is ApacheBench, Version 2.3 <$Revision: 1638069 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.12
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /phpinfo.php
Document Length:        209 bytes

Concurrency Level:      1000
Time taken for tests:   5.136 seconds
Complete requests:      1000
Failed requests:        125
   (Connect: 0, Receive: 0, Length: 125, Exceptions: 0)
Non-2xx responses:      885
Keep-Alive requests:    877
Total transferred:      374749 bytes
HTML transferred:       184965 bytes
Requests per second:    194.69 [#/sec] (mean)
Time per request:       5136.408 [ms] (mean)
Time per request:       5.136 [ms] (mean, across all concurrent requests)
Transfer rate:          71.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   18  25.2      0      73
Processing:     1 1342 2013.5     12    5060
Waiting:        1  728 1499.3     11    5060
Total:          1 1360 2023.8     45    5130

Percentage of the requests served within a certain time (ms)
  50%     45
  66%   1137
  75%   2201
  80%   4997
  90%   5005
  95%   5128
  98%   5129
  99%   5129
 100%   5130 (longest request)
[root@bwebhttpd-2.4.12]# 

3.2 華爲雲壓測

[root@hwweb02 httpd-2.4.12]# /usr/local/apache2/bin/ab -c 1000 -n 1000 http://127.0.0.1/phpinfo.php
    This is ApacheBench, Version 2.3 <$Revision: 1638069 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 127.0.0.1 (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests


    Server Software:        Apache/2.4.12
    Server Hostname:        127.0.0.1
    Server Port:            80

    Document Path:          /phpinfo.php
    Document Length:        209 bytes

    Concurrency Level:      1000
    Time taken for tests:   0.642 seconds
    Complete requests:      1000
    Failed requests:        0
    Non-2xx responses:      1000
    Total transferred:      387000 bytes
    HTML transferred:       209000 bytes
    Requests per second:    1558.26 [#/sec] (mean)
    Time per request:       641.742 [ms] (mean)
    Time per request:       0.642 [ms] (mean, across all concurrent requests)
    Transfer rate:          588.91 [Kbytes/sec] received

    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        1   16  11.5      8      30
    Processing:     8  101 170.6     20     609
    Waiting:        2   98 171.8     18     609
    Total:         15  116 176.2     25     634

    Percentage of the requests served within a certain time (ms)
      50%     25
      66%     45
      75%    231
      80%    234
      90%    238
      95%    632
      98%    634
      99%    634
     100%    634 (longest request)
    [root@hwweb02 httpd-2.4.12]#

下面是加帶了-k參數。表示不釋放鏈接:

[root@hwweb02 httpd-2.4.12]# /usr/local/apache2/bin/ab -k -c 1000 -n 1000 http://127.0.0.1/phpinfo.php
    This is ApacheBench, Version 2.3 <$Revision: 1638069 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 127.0.0.1 (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests


    Server Software:        Apache/2.4.12
    Server Hostname:        127.0.0.1
    Server Port:            80

    Document Path:          /phpinfo.php
    Document Length:        209 bytes

    Concurrency Level:      1000
    Time taken for tests:   6.265 seconds
    Complete requests:      1000
    Failed requests:        100
       (Connect: 0, Receive: 0, Length: 100, Exceptions: 0)
    Non-2xx responses:      910
    Keep-Alive requests:    900
    Total transferred:      385300 bytes
    HTML transferred:       190190 bytes
    Requests per second:    159.62 [#/sec] (mean)
    Time per request:       6264.951 [ms] (mean)
    Time per request:       6.265 [ms] (mean, across all concurrent requests)
    Transfer rate:          60.06 [Kbytes/sec] received

    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0   10  12.9      0      29
    Processing:     0 1425 2150.0      8    6235
    Waiting:        0  934 1811.3      8    6235
    Total:          0 1434 2155.1      8    6261

    Percentage of the requests served within a certain time (ms)
      50%      8
      66%   1402
      75%   2419
      80%   3416
      90%   5004
      95%   6260
      98%   6261
      99%   6261
     100%   6261 (longest request)
    [root@hwweb02 httpd-2.4.12]# 

3.3 idc機房測試

[root@idc_web~]# /usr/bin/ab -k -c 1000 -n 1000 http://127.0.0.1/phpinfo.php
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 127.0.0.1 (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests


    Server Software:        Apache/2.2.15
    Server Hostname:        127.0.0.1
    Server Port:            80

    Document Path:          /phpinfo.php
    Document Length:        286 bytes

    Concurrency Level:      1000
    Time taken for tests:   0.341 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Non-2xx responses:      1000
    Keep-Alive requests:    0
    Total transferred:      466000 bytes
    HTML transferred:       286000 bytes
    Requests per second:    2929.00 [#/sec] (mean)
    Time per request:       341.414 [ms] (mean)
    Time per request:       0.341 [ms] (mean, across all concurrent requests)
    Transfer rate:          1332.92 [Kbytes/sec] received

    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:       23   41   9.9     42      57
    Processing:    78  177  65.4    178     274
    Waiting:       72  176  65.4    177     274
    Total:        120  218  72.0    234     316

    Percentage of the requests served within a certain time (ms)
      50%    234
      66%    278
      75%    288
      80%    294
      90%    307
      95%    312
      98%    315
      99%    316
     100%    316 (longest request)
    [root@idc_web~]# 

參考文章地址:http://blog.csdn.net/chenxiaohua/article/details/2047757
參考文章地址:http://blog.chinaunix.net/uid-7411781-id-2056132.html
參考文章:http://www.cnblogs.com/shipengzhi/archive/2012/10/09/2716766.html

相關文章
相關標籤/搜索