Google Code Prettify

2012年7月2日 星期一

Apache http Server 2.4 效能解放


Apache 2.4 宣佈已經可以跟 Nginx比拼了
但很多網路文章卻測不出這個效能

一開始我也沒辦法解放它的效能
經過數次的安裝移除的循環
發現一個重要的參數: --with-mpm
必須安裝為 event Multi-Processing Module
這就是解放效能的所在囉

什麼是 event module, 其實就是 linux EPoll,Nginx 也是應用這個模式


Apache 2.4 安裝步驟

#安裝 APR
tar -zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apache-apr --enable-nonportable-atomics=yes
make
sudo make install

#安裝 APR-UTIL apr-util
tar -zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apache-apr --with-apr=/usr/local/apache-apr
make
sudo make install

unzip -o pcre-8.30.zip
cd pcre-8.30
./configure --prefix=/usr/local/pcre --enable-utf --enable-unicode-properties
make
sudo make install

#安裝 apache server
1. tar -zxvf httpd-2.4.2.tar.gz

2. cd httpd-2.4.2

3. ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apache-apr --with-apr-util=/usr/local/apache-apr --with-pcre=/usr/local/pcre --with-mpm=event \
--enable-nonportable-atomics=yes \
--enable-mods-shared=all \
--enable-expires=shared \
--enable-headers=shared \
--enable-reqtimeout=shared \
--enable-ssl=shared \
--enable-rewrite=shared \
--enable-speling=shared \
--enable-proxy=shared \
--enable-proxy-connect=shared \
--enable-proxy-ajp=shared \
--enable-proxy-balancer=shared \
--enable-proxy-express=shared \
--enable-info=shared \
--enable-heartbeat=shared \
--enable-heartmonitor=shared \
--enable-ratelimit=shared \
--enable-remoteip=shared \
--enable-allowmethods=shared

4. make

5. sudo make install

6.Check Apache MPM 是 event
/usr/local/apache2.4/bin/httpd -l
/usr/local/apache2.4/bin/httpd -V | grep MPM

#效能調整
#修改 httpd-mpm.conf 下的mpm_event_module

    StartServers             2
    MinSpareThreads         25
    MaxSpareThreads         75
    ThreadsPerChild         25
    MaxRequestWorkers      150
    MaxConnectionsPerChild   0

沒有留言: