5七月/10關閉
Apache2 mod_cband
注意:該模組比較吃資源,使用在連線頻繁的主機上,將造成loading大幅增加至少7倍以上!
mod_cband是一個可以使用在apache2上面,用來管制虛擬主機連線數及頻寬的模組,
該模組的開發首頁是http://codee.pl/cband.html,目前的最新版本是0.9.7.5。
進行測試的環境配置如下,
apache版本:2.0.63
平均連線數:1200
平均loading:2.5
Step1. 安裝mod_cband,下載後解開,執行以下command
./configure --with-apxs=/usr/local/apache/bin/apxs;make;make install
Step2. 編輯httpd.conf
# 將mod_cband模組掛載進來
LoadModule cband_module modules/mod_cband.so
# 加上這兩個參數優化效能
CBandScoreFlushPeriod
CBandRandomPulse On
# moniter cband status
<Location /cband-status>
<Location /cband-status>
SetHandler cband-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
# 在VirtualHost中加入CBandSpeed設定
<VirtualHost 127.0.0.1:80>
ServerName test.com
CBandSpeed 0 400 450 #頻寬不設限,只限制連線數
CBandScoreboard /var/log/cband/test.com
</VirtualHost>
Step3. 重新啟動Apache
CBandSpeed的官方說明:
Name | CBandSpeed |
Description | Specifies a maximal speed for a virtualhost |
Context | |
Syntax | CBandSpeed kbps rps max_conn kbps - maximal transfer speed in [kMG]bps or [kMG]B/s rps - maximal requests per second max_conn - maximal number of simultaneous connections |
Example | CBandSpeed 1024 10 30 Specifies maximal speed 1024kbps (1024 * 1024 bits per second), maximal 10 requests per second and with a maximum of 30 open connections NOTE: This feature is available from version 0.9.6.0 |