Apache優化深入
/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 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 \
--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 # 最小空閑進程數
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優化深入