/usr/bin/ab
ab -n2000 -c800 www.benet.com/index.html
//发送2000请求,并发连接800
可以关闭压缩功能,观察测压结果
**
Apache工作模式 ?
event模式(默认) ?查看工作模式 ?cd /usr/local/httpd/bin ???
./httpd -l ?????
yum install lsof -y
**lsof -i :80
COMMAND ?PID ??USER ??FD ??TYPE DEVICE SIZE/OFF NODE NAME
httpd ??2266 ??root ???3u ?IPv4 ?15838 ?????0t0 ?TCP 192.168.100.101:http (LISTEN)
httpd ??2267 daemon ???3u ?IPv4 ?15838 ?????0t0 ?TCP 192.168.100.101:http (LISTEN)
httpd ??2268 daemon ???3u ?IPv4 ?15838 ?????0t0 ?TCP 192.168.100.101:http (LISTEN)
httpd ??2269 daemon ???3u ?IPv4 ?15838 ?????0t0 ?TCP 192.168.100.101:http (LISTEN)
一个root主进程带有多个daemon子进程**
prefork模式 ???
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--with-mpm=prefork \
--enable-expires \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
**vim /etc/httpd.conf
Include conf/extra/httpd-mpm.conf
vim /usr/local/httpd/conf/extra/httpd-mpm.conf
<IfModule mpm_prefork_module>
StartServers ????????????10 ??????# 启动时进程数
MinSpareServers ?????????10 ??????# 最小空闲进程数
MaxSpareServers ????????50 ???????# 最大空闲进程数
MaxRequestWorkers ?????150 ???????#最大并发进程数
MaxConnectionsPerChild ??0 ???????# 最大连接数限制
</IfModule>**
worker模式 ????
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--with-mpm=worker \
--enable-expires \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi ?
**vim /etc/httpd.conf
Include conf/extra/httpd-mpm.conf
<IfModule mpm_worker_module>
StartServers ????????????2 ?????#启动时进程数
MinSpareThreads ????????25 ?????#最小空闲线程数
MaxSpareThreads ????????75 ?????#最大空闲线程数
ThreadsPerChild ????????25 ?????#每个进程可以启动的线程数量
MaxRequestWorkers ?????150 ?????#线程数量最大值
MaxConnectionsPerChild ??0 ?????#最大连接数限制
ThreadLimit ????????????64 ?????#每个进程可以启动的线程数量上限值
</IfModule>
**
**目录属性 ???
vim /etc/httpd.conf
<Directory "/usr/local/httpd/htdocs">
Options Indexes FollowSymLinks
AllowOverride None<RequireAll> ????Require all granted ?????//允许所有 ????Require not ip 192.168.176.140 ??//不让176.140访问</RequireAll>
</Directory>**
Apache优化深入
原文地址:http://blog.51cto.com/13706698/2165573