Brief introduction
Stress testing is an essential part of the performance tuning process. It is only when the server is under high pressure that it can truly reflect the problems exposed by the various settings.
Performance testing tools are now most commonly found in the following categories: AB, Http_load, Webbench, siege.
AB's Principle
?? The AB command creates multiple concurrent access threads, simulating multiple visitors accessing a URL address at the same time. Its test target is URL-based, so it can be used to test the load pressure of Apache, as well as other Web servers such as Nginx, Tomcat, and IIS.
?? The AB command is very low on the computer that emits the load, and it does not occupy a high CPU or consume a lot of memory. But it will cause a huge load on the target server, which is similar in principle to ccxxx. You also need to be aware of your own testing, or too much load at a time. May cause the target server resources to run out, serious even causes the panic.
Experimental environment
- System Environment: centos6.5
- Server IP Address: 192.168.100.103
- Yum Mount directory:/mnt/sr0
- Related source package: Baidu Cloud download?? Password: PKO3
Build step one, prepare for work 1, close the firewall and SELinux
[Email protected] ~]# chkconfig iptables off #随开机关闭iptables
[Email protected] ~]# Vim/etc/sysconfig/selinux
[email protected] ~]# reboot #重启生效
2. Uninstall to install httpd related package in RPM mode
[Email protected] ~]# Rpm-qa | grep "httpd"
[email protected] ~]# Yum remove httpd #卸载httpd相关包
3. Build a DNS server
If you don't have a friend for the above two services, check out my other posts for more information
http://blog.51cto.com/11905606/2156944
Second, build httpd service 1, install GCC, gcc-c++, make, ARP, Arp-util, Pcre and other toolkits
[Email protected] ~]# yum-y install gcc gcc-c++ make Zlib-devel #安装C语言编译器以及make
[Email protected] ~]# TAR-ZXVF apr-1.4.6.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/apr-1.4.6/
[[email protected] apr-1.4.6]#./configure prefix=/usr/local/apr && make && make install
[Email protected] ~]# TAR-ZXVF apr-util-1.4.1.tar.gz-c/usr/src/
[Email protected] ~]# CD/USR/SRC/APR-UTIL-1.4.1/
[Email protected] apr-util-1.4.1]#/configure prefix=/usr/local/apr-util--with-apr=/usr/local/apr && Make & amp;& make Install
[Email protected] ~]# TAR-ZXVF pcre-8.10.tar.gz-c/usr/src #支持正则
[Email protected] ~]# cd/usr/src/pcre-8.10/
[[email protected] pcre-8.10]#./configure prefix=/usr/local/pcre && make && make install
2. Configuring and installing Apache
[Email protected] ~]# tar zxvf httpd-2.4.2.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/httpd-2.4.2/
[Email protected] httpd-2.4.2]#/configure \
--PREFIX=/USR/LOCAL/HTTPD \
--WITH-APR=/USR/LOCAL/APR \
--with-pcre=/usr/local/pcre \
--enable-deflate \
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
Parameter resolution:
Prefix: Specifying the installation directory
Enable-deflate: Enable Mod_deflate module
ENABLE-SO: Enable dynamic load module support, what functions are required to dynamically load
Enable-rewrite: Enable Web address rewriting to implement pseudo-static
Enable-charset-lite: Default Character Set
Enable-cgid: Enable Cgid
[[email protected] httpd-2.4.2]# make && make install #编译及编译安装
3. Adding system Services
[Email protected] ~]# CP/USR/LOCAL/HTTPD/BIN/APACHECTL/ETC/INIT.D/HTTPD
[Email protected] ~]# VIM/ETC/INIT.D/HTTPD
lines 2nd, 32 add the following parameters:
# chkconfig:2345 85 15
# Description:apache is a world Wide Web server.
[Email protected] init.d]# chmod +x/etc/init.d/httpd
[Email protected] init.d]# chkconfig--add httpd
4, the establishment of soft links, easy to manage
[Email protected] ~]# mkdir-p/etc/httpd
[Email protected] ~]# ln-s/usr/local/httpd/conf//etc/httpd/#优化配置文件路径
[Email protected] ~]# ln-s/usr/local/httpd/bin/*/usr/local/bin/#优化命令路径
5. Modify the configuration file
[Email protected] ~]# vim/etc/httpd/conf/httpd.conf
Modify the following parameters:
ServerName www.bt.com:80 #填写完全主机名
Listen 192.168.100.103:80 #监听本地IP
6. Start httpd Service
[[Email protected] ~]# service httpd start
[Email protected] ~]# NETSTAT-ANPT | grep ': 80 '
Second, configure Apache to achieve page compression 1, edit the default home page
[email protected] ~]# CP qingzi.jpg/usr/local/httpd/htdocs/#将图片拷贝到站点目录中
[Email protected] ~]# cd/usr/local/httpd/htdocs/
[Email protected] htdocs]# vim index.html
?? <body>
???? ???? #首页添加图片
?? </body>
2. Modify the master configuration file
[Email protected] ~]# vim/etc/httpd/conf/httpd.conf
102 rows or so, open the Deflate module
LoadModule Deflate_module modules/mod_deflate.so
At the end, add the following parameters:
<ifmodule deflate_module>
Addoutputfilterbytype DEFLATE text/html text/plain text/css text/xml text/javascript #对html, CSS, and other content enable gzip compression
Deflatecompressionlevel 9 #压缩级别是9, high-level compression, the higher the level, the smaller the compression
Setoutputfilter DEFLATE #启用deflate模块对本站点的输出进行gzip压缩
</IfModule>
3, check whether the Mod_deflate module is installed
[Email protected] ~]# apachectl-t-D dump_modules | grep ' deflate '
[Email protected] ~]#/etc/init.d/httpd restart #重启httpd服务
4. Use Fiddler to capture the package view
Third, using the AB tool for stress testing
[Email protected] ~]# cd/usr/local/httpd/bin/
[email protected] bin]# LL
1, the pressure test
[Email protected] ~]# ab-n3000-c1000 www.bt.com/index.html
-N: Sum of requests, that is, total number of request requests, number of accesses
-C: Number of concurrent users, number of concurrent links
2. Turn off the compression function of Web page
[Email protected] ~]# vim/etc/httpd/conf/httpd.conf
[Email protected] ~]#/etc/init.d/httpd restart #重新启动服务
3, the pressure test again
[Email protected] ~]# ab-n3000-c1000 www.bt.com/index.html
Apache Performance stress test for Web sites