300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 云服务器 性能测试之web压力测试

云服务器 性能测试之web压力测试

时间:2018-12-13 16:49:45

相关推荐

云服务器 性能测试之web压力测试

前言:现在云服务器是主流,成了许多中小型公司的首选服务器,但是云服务器都是虚拟机,所以性能是一大疑问,这里就开始简单介绍云服务器的性能测试,云端web服务器的压力测试。

Linux下常用的四款Web服务器压力测试工具(http_load、webbench、ab、siege),这里采用apache自带的ab工具来测试。

1,开始安装apache

前期准备:

yum install gcc* -y

yum install libtool* -y

1.1,去官网下载

apache,/download.cgi#apache24

下载软件包是:httpd-2.4.12.tar.gz

解压tar -zxvf httpd-2.2.6.tar.gz,完成之后,会在当前目录出现一个httpd-2.2.6目录,然后顺序执行如下命令改名:

tar -zxvf httpd-2.2.6.tar.gzmv httpd-2.2.6 apachecd 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-utilchecking for chosen layout... Apachechecking for working mkdir -p... yeschecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuconfigure: 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]#

<版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!>

原博客地址: /mchdba/article/details/46381741

原作者:黄杉 (mchdba)

报错APR…问题

1.2 解决apr not found问题

去/download.cgi下载

wget /dist/apr/apr-1.4.6.tar.gz,然后源码安装

[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组件:

[root@bwebdata]# wget //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*

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 /的错误

查看下是否有pcre参数

[root@bwebhttpd-2.4.12]# ./configure -help | grep pcre

–with-pcre=PATH Use external PCRE library

[root@bwebhttpd-2.4.12]#

没有这个参数,所以需要重新下载安装:

下载pcre,下载地址一:/projects/pcre 下载地址二:http://ftp./pcre/

[root@bwebdata]# wget http://ftp./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 startAH00558: 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/bintotal 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 0 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.phpThis is ApacheBench, Version 2.3 <$Revision: 1638069 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.4.12Server Hostname: 127.0.0.1Server Port: 80Document Path:/phpinfo.phpDocument Length: 209 bytesConcurrency Level:1000Time taken for tests: 0.676 secondsComplete requests:1000Failed requests: 0Non-2xx responses:1000Total transferred:387000 bytesHTML transferred: 209000 bytesRequests 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] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 4 28 20.11465Processing:4 90 155.118608Waiting: 3 87 156.213608Total: 16 118 169.929665Percentage of the requests served within a certain time (ms)50%2966%5275% 26680% 26790% 27095% 66298% 66399% 663100% 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.phpThis is ApacheBench, Version 2.3 <$Revision: 1638069 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.4.12Server Hostname: 127.0.0.1Server Port: 80Document Path:/phpinfo.phpDocument Length: 209 bytesConcurrency Level:1000Time taken for tests: 5.136 secondsComplete requests:1000Failed requests: 125(Connect: 0, Receive: 0, Length: 125, Exceptions: 0)Non-2xx responses:885Keep-Alive requests: 877Total transferred:374749 bytesHTML transferred: 184965 bytesRequests 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] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 0 18 25.2073Processing:1 1342 .512 5060Waiting: 1 728 1499.311 5060Total:1 1360 .845 5130Percentage of the requests served within a certain time (ms)50%4566% 113775% 20% 499790% 500595% 512898% 512999% 5129100% 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.phpThis is ApacheBench, Version 2.3 <$Revision: 1638069 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.4.12Server Hostname: 127.0.0.1Server Port: 80Document Path:/phpinfo.phpDocument Length: 209 bytesConcurrency Level:1000Time taken for tests: 0.642 secondsComplete requests:1000Failed requests: 0Non-2xx responses:1000Total transferred:387000 bytesHTML transferred: 209000 bytesRequests 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] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 1 16 11.5830Processing:8 101 170.620609Waiting: 2 98 171.818609Total: 15 116 176.225634Percentage of the requests served within a certain time (ms)50%2566%4575% 23180% 23490% 23895% 63298% 63499% 634100% 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.phpThis is ApacheBench, Version 2.3 <$Revision: 1638069 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.4.12Server Hostname: 127.0.0.1Server Port: 80Document Path:/phpinfo.phpDocument Length: 209 bytesConcurrency Level:1000Time taken for tests: 6.265 secondsComplete requests:1000Failed requests: 100(Connect: 0, Receive: 0, Length: 100, Exceptions: 0)Non-2xx responses:910Keep-Alive requests: 900Total transferred:385300 bytesHTML transferred: 190190 bytesRequests 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] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 0 10 12.9029Processing:0 1425 2150.08 6235Waiting: 0 934 1811.38 6235Total:0 1434 2155.18 6261Percentage of the requests served within a certain time (ms)50%866% 140275% 241980% 341690% 500495% 626098% 626199% 6261100% 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.phpThis is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.2.15Server Hostname: 127.0.0.1Server Port: 80Document Path:/phpinfo.phpDocument Length: 286 bytesConcurrency Level:1000Time taken for tests: 0.341 secondsComplete requests:1000Failed requests: 0Write errors: 0Non-2xx responses:1000Keep-Alive requests: 0Total transferred:466000 bytesHTML transferred: 286000 bytesRequests 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] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 23 41 9.94257Processing: 78 177 65.4 178274Waiting: 72 176 65.4 177274Total: 120 218 72.0 234316Percentage of the requests served within a certain time (ms)50% 23466% 27875% 28880% 29490% 30795% 31298% 31599% 316100% 316 (longest request)[root@idc_web~]#

参考文章地址:/chenxiaohua/article/details/2047757

参考文章地址:/uid-7411781-id-2056132.html

参考文章:/shipengzhi/archive//10/09/2716766.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。