本页主题: Installation-安装(略) Apache 2 Bandwidth Quota and Throttling 打印 | 加为IE收藏 | 复制链接 | 收藏主题 | 上一主题 | 下一主题

admin
级别: 管理员


精华: 1
发帖: 4646
威望: 47 点
金钱: 23190 RMB
贡献值: 0 点
注册时间:2006-10-09
最后登录:2008-12-01

 Installation-安装(略) Apache 2 Bandwidth Quota and Throttling

Installation-安装(略)
官方网址:[/url][url=http://cband.linux.pl/]http://cband.linux.pl
Configuration Directives  配置说明New commands from 0.9.7.0 version - 0.9.7.0 版命令:
CBandDefaultExceededCode - the http code sent to the user when the quota is exceeded 当超出流量时,发送给用户的http代码

transfer speeds  传送速度:
kbps, Mbps, Gbps - multiples of "bits per second", respectively: 1024, 1024*1024 and 1024*1024*1024 bps 位/秒
kb/s, Mb/s, Gb/s - multiples of "bytes per second", respectively: 1024, 1024*1024 and 1024*1024*1024 b/s 字节/秒
defaults to kbps 默认是kbps
transfer quotas 传送带宽:
K, M, G - multiples of bytes, respectively: 1000, 1000*1000 and 1000*1000*1000 bytes 字节
Ki, Mi, Gi - multiples of bytes, respectively: 1024, 1024*1024 and 1024*1024*1024 bytes 字节
defaults to K 默认是K
time periods 时间周期:
S, M, H, D, W - multiples of seconds: Seconds, Minutes, Hours, Days, Weeks; respectively: 1, 60, 3600, 86400, 604800 seconds 秒、分、小时、天、周
defaults to S 默认是秒
 
Name
CBandDefaultExceededURL
Description
Default URL where mod_cband should redirect all requests to the virtualhost or user when the configured transfer limit is exceeded
NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
当超流量时,跳转的URL。注意:如果没有配置此项,将发送503。
Context
Server config
Syntax
CBandDefaultExceededURL URL
Name
CBandDefaultExceededCode NEW
Description
The http code sent to the user when the configured transfer is exceeded
当流量超出时,发送给用户的http代码
Context
Server config
Syntax
CBandDefaultExceededCode HTTP_CODE
Example
CBandDefaultExceededCode 509
Name
CBandScoreFlushPeriod
Description
Specifies a period after which the score for the virtualhost or user is written to the scoreboard file. Use this to improve mod_cband's performance
定义scoreboard文件写入的周期,用此提升mod_cband的性能。
Default
1
Context
Server config
Syntax
CBandScoreFlushPeriod number_of_requests
Example
CBandScoreFlushPeriod 100
Any virtualhost's or user's scoreboard will be saved after 100 requests
所有虚拟主机和用的scoreboard写入周期是100次请求
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
指定最大速度为1024kbps,每秒最大请求数10,最大连接数30
NOTE:This feature is available from version 0.9.6.0
注意:此功能在0.9.6.0版以后支持
Name
CBandRemoteSpeed
Description
Specifies maximal speed for any remote client
定义客户端的最大速度
Context
Syntax
CBandRemoteSpeed 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
CBandRemoteSpeed 20kb/s 3 3
Specifies maximal speed 20kB/s (20 * 1024 bytes per second), maximal 3 requests per second and 3 open connections for any remote client
定义每客户端最大速度为20kB/s,每秒最大请求数为3,最大连接数为3
NOTE:This feature is available from version 0.9.6.1-rc2
注意:此功能在0.9.6.1-rc2之后版本支持
Name
CBandClassRemoteSpeed
Description
Specifies maximal speed for any remote client from some destination class
定义某类别网络中,客户端的最大速度
Context
Syntax
CBandClassRemoteSpeed class_name kbps rps
class_name - name of defined destination class
被定义的类名称
kbps - maximal transfer speed in kbps or kB/s
最大传送速度
rps - maximal requests per second
每秒最大请求数
max_conn - maximal number of simultaneous connections
最大连接数
Example
CBandClassDst 66.249.64/24
CBandClassDst 66.249.65/24
CBandClassDst 66.249.79/24
CBandClassRemoteSpeed googlebot_class 20kb/s 2 3
-Specifies maximal speed 20kB/s (20 * 1024 bytes per second), maximal 2 requests per second and 3 open connections for any remote client from class googlebot_class
-定义googlebot_class类中的客户端最大速度为20kB/s,每秒最大请求数为2,最大连接数为3
NOTE:This feature is available from version 0.9.6.1-rc2
注意:此功能在0.9.6.1-rc2版之后提供
Name
CBandRandomPulse
Description
Turns On or Off the random pulse generator for data sending
r.p.g.开关
Random pulse generator is a part of the speed-limiting implementation of mod_cband. This directive changes the way a connection's speed is determined and enforced. The connections' speeds are measured within some time period and then provided for in that period. When r.p.g. is enabled this period is chosen randomly, providing for a statisticaly saner load distribution. Disabling this causes spikes both in bandwidth and cpu usages
r.p.g.是mod_cband速度限制的一种方式。它指定了连接检测采样的方式。打开此功能,将持续滚动采样。如果带宽和CPU占用不稳定的时候,关掉此功能。
Context
Global
Syntax
CBandRandomPulse On/Off
Name
CBandLimit
Description
Specifies bandwidth limit for virtualhost
限制虚拟主机的流量
Context
Syntax
CBandLimit limit
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
流量限制单位,可以用K、M、G、Ki、Mi、Gi
Example
CBandLimit 10M
Specifies 10 * 1000 * 1000 bytes bandwidth quota
限制流量为10M
CBandLimit 10Mi
Specifies 10 * 1024 * 1024 bytes bandwidth quota
限制流量为10Mi
IMPORTANT NOTE: the meaning of K, M and G changed with version 0.9.6.0. Check your config
重要提示:K、M和G的计量在0.9.6.0版后发生变化,检查你的配置。
Name
CBandClassLimit
Description
Specifies bandwidth limit for virtualhost's destination class
定义虚拟主机目标类别的流量
Context
Syntax
CBandClassLimit class_name limit
class_name - the name of defined class
类名称
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
流量限制单位,可以用K、M、G、Ki、Mi、Gi
IMPORTANT NOTE: the meaning of K, M and G changed with version 0.9.6.0. Check your config
重要提示:K、M、G的衡量在0.9.6.0版后发生变化,检查你的配置。
Name
CBandExceededURL
Description
Specifies a URL where mod_cband should redirect all requests to a virtualhost when the configured transfer limit is exceeded NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
指定当虚拟主机超出带宽或流量时,跳转的URL。提示:如果没有配置此项,将发送标准的503。
Context
Syntax
CBandExceededURL URL

Name
CBandExceededSpeed
Description
Specifies maximal speed to which mod_cband slows down a virtualhost when the configured transfer limit is exceeded
定义当虚拟主机流量或带宽超出限制时,mod_cband将调节的最大速度
Context
Syntax
CBandExceededSpeed kbps rps max_conn
kbps - maximal transfer speed in kbps or kB/s
最大传送速度,kbps或kB/s
rps - maximal requests per second
每秒最大请求数
max_conn - maximal number of simultaneous connections
最大连接数
NOTE:This feature is available from version 0.9.6.0
提示:此功能在0.9.6.0版以后提供
Name
CBandScoreboard
Description
Specifies virtualhost's scoreboard file
指定虚拟主机的scoreboard文件按
Context
Syntax
CBandScoreboard path
NOTE: The path must be writeable for the apache-user
提示:路径对于Apache用户必须可写
Name
CBandPeriod
Description
Specifies a period after which a virtualhost's usages are cleared
定义虚拟主机使用情况清空的周期
Context
Syntax
CBandPeriod period
period - available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
可用单位:S(秒)、M(分)、H(小时)、D(天)、W(周)
Example
CBandPeriod 1W
CBandPeriod 14D
CBandPeriod 60M
Name
CBandPeriodSlice
Description
Specifies the period slice length
定义CBandPeriod周期内,分部分计算的时间长度
Default
slice_len = limit
Context
Syntax
CBandPeriodSlice slice_length
Example
CBandLimit 100G
CBandPeriod 4W
CBandPeriodSlice 1W
A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G ...
一个周期将被分成4个小部分(4周/1周=4)。每部分限制流量100G/4=25G。一周之后slice限制将是50G,两周后将是75G...
Name

Description
Define a new cband user
定义cband用户
Context
Server config
Syntax
user_name>
Name
CBandUserSpeed
Description
Specifies maximal speed for a cband user
定义cband用户的最大带宽
Context
Syntax
CBandUserSpeed kbps rps max_conn
kbps - maximal transfer speed in kbps or kB/s
最大速度
rps - maximal requests per second
每秒请求数
max_conn - maximal number of simultaneous connections
最大连接数
Example
CBandUserSpeed 100kb/s 10 5
Specifies maximal speed 100 kB/s (100 * 1024 bytes per second), maximal 10 requests per second and 5 open connections
定义用户的最大熟读为100kB/s,每秒最多10个请求,最大连接数为5
NOTE:This feature is available from version 0.9.6.0
提示:此功能在0.9.6.0以后提供
Name
CBandUserLimit
Description
Specifies bandwidth limit for a cband user
指定cband user的流量
Context
Syntax
CBandUserLimit limit
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
流量可用单位K、M、G、Ki、Mi、Gi
Example
CBandUserLimit 10M
Specifies 10 * 1000 * 1000 bytes bandwidth quota
指定用户流量为10M
CBandUserLimit 10Mi
Specifies 10 * 1024 * 1024 bytes bandwidth quota
指定用户流量为10Mi
IMPORTANT NOTE: the meaning of K, M and G changed with version 0.9.6.0. Check your config
重要提示:K、M和G的计量在0.9.6.0版之后发生变化,检查你的配置。
Name
CBandUserClassLimit
Description
Specifies bandwidth limit for a cband user's destination class
指定cband user类的流量
Context
Syntax
CBandUserClassLimit class_name limit
class_name - the name of defined class
类名称
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
流量大小单位,可用K、M、G、Ki、Mi、Gi
IMPORTANT NOTE: the meaning of K, M and G changed with version 0.9.6.0. Check your config
重要提示:在0.9.6.0版之后,K、M和G的计算方式发生变化,检查你的配置
Name
CBandUserExceededURL
Description
Specifies a URL where mod_cband should redirect all requests to user's virtualhost when the configured transfer limit is exceeded
指定当cband user超出限制时,跳转的URL
NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
提示:如果没有定义此项,将发送标准的503
Context
Syntax
CBandUserExceededURL URL
Name
CBandUserExceededSpeed
Description
Specifies maximal speed to which mod_cband slows down user when the configured transfer limit is exceeded
定义当cband user超出限制时,mod_cband将调节的速度
NOTE: CBandUserExceededURL must not be used if you want to only slow down user's pages with CBandUserExceededSpeed directive
提示:只有当CBandUserExceededURL没有设定时,此项才生效
Context
Syntax
CBandUserExceededSpeed kbps rps max_conn
kbps - maximal transfer speed in kbps or kB/s
最大速度
rps - maximal requests per second
每秒请求数
max_conn - maximal number of simultaneous connections
最大连接数
NOTE:This feature is available from version 0.9.6.0
提示:从0.9.6.0版之后支持此功能
Name
CBandUserScoreboard
Description
Specifies a user's scoreboard file
定义用户的scoreboard文件
Context
Syntax
CBandUserScoreboard path
NOTE: The path must be writeable for the apache-user
提示:目录必须允许apache用户写入
Name
CBandUserPeriod
Description
Specifies a period after which a user's usages are cleared
定义cband user计算周期
Context
Syntax
CBandUserPeriod period
period - available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
可用单位S(秒)、M(分)、H(小时)、D(天)、W(周)
Example
CBandUserPeriod 1W
CBandUserPeriod 14D
CBandUserPeriod 60M
Name
CBandUserPeriodSlice
Description
Specifies a period slice length
定义CBandUserPeriod的分割
Default
slice_len = limit
Context
Syntax
CBandUserPeriodSlice slice_length
Example
CBandUserLimit 100G
CBandUserPeriod 4W
CBandUserPeriodSlice 1W
A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G ...
CBandUserPeriod将被分割成4个部分(4W/1W=4)。每部分限制流量100G/4=25G。一周之后部分限制将为50G,两周后为75G...
Status Handler Configuration Example
状态配置实例


To view actual bandwidth limits, usages, users, scoreboards, add the following lines into the config file:
要观察时势的流量、使用、用户、scoreboard,添加以下内容到配置文件:
SetHandler cband-status
SetHandler cband-status-me

Then you can access the status page with a URL like:
这样,你就可以通过以下地址来访问
[/url][url=http://server_name/cband-status]http://server_name/cband-status
[/url][url=http://server_name/cband-status-me]http://server_name/cband-status-me
在0.9.5-rc1之后的版本中,可以通过XML格式来观察
[/url][url=http://server_name/cband-status?xml]http://server_name/cband-status?xml
[/url][url=http://server_name/cband-status-me?xml]http://server_name/cband-status-me?xml
Bandwidth Speed Configuration Example
流量带宽配置实例
    DocumentRoot /var/www/xyz.org/
    ServerName xyz.org
    CustomLog /var/log/apache2/xyz.org.access combined
    ErrorLog /var/log/apache2/xyz.org.access.error
    RewriteEngine On
    RewriteOptions inherit
    # Maximal 1024kbps speed for this virtualhost
    # 最大带宽1024kbps
    # Maximal 10 requests per second for this virtualhost
    # 每秒最多10个请求
    # Maximal 30 open connections for this virtualhost
    # 最大连接为30个
    CBandSpeed 1024 10 30

    # Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client
    # 每个远程客户端最大带宽10kB/s,每秒最多3个请求,最大连接为2个
    CBandRemoteSpeed 10kb/s 3 2
    # Maximal 20kB/s speed, 2 requests/s and 3 open connections for remote
    # clients from class googlebot_class :P
    # 对于googlebot_class类的远程用户,最大带宽为20kB/s,每秒最多2个请求,最大连接为3个
    CBandClassRemoteSpeed googlebot_class 20kb/s 2 3

Bandwidth Quota Configuration Example
流量限制配置实例per-virtualhost bandwidth limiting configuration
每虚拟主机流量配置Next, you may define virtualhost's bandwidth limits, URL location and the path to scoreboard files for individual virtualhosts:
下面,你可以订制虚拟主机的流量限制、URL和scoreboard文件
# specify default 'bandwidth exceeded' location
# 定义超出流量之后跳转的URLCBandDefaultExceededURL
[/url][url=http://haha.org/bandwidth_exceeded.html]http://haha.org/bandwidth_exceeded.html

    DocumentRoot /var/www/xyz.org/
    ServerName xyz.org
    CustomLog /var/log/apache2/xyz.org.access combined
    ErrorLog /var/log/apache2/xyz.org.access.error
    RewriteEngine On
    RewriteOptions inherit
    # 100MB virtualhost bandwidth limit
    # 流量限制为100M
    CBandLimit 100000
    # redirect to [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    # 当超过流量时,跳转URL到[/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    CBandExceededURL [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # virtualhost's scoreboard file
    # 虚拟主机的scoreboard文件
    CBandScoreboard /var/run/apache2/xyz.org.scoreboard
    # a period of time after which the scoreboard will be cleared (30 minutes)
    # (only in >=0.9.5-rc2)
    # scoreboard清空周期(30分钟),仅在0.9.5-rc2之后版本支持
    CBandPeriod 30M


per-user bandwidth limiting configuration (only in versions >=0.9.1)
按用户指定流量(仅限0.9.1之后版本)
In versions >=0.9.1 you can define limits for users and assign virtualhosts to them
在0.9.1版之后,你可以指定用户限制然后将虚拟主机分配给用户
--------------------------------------------------------------------------------
# define user‘dembol’
# 定义用户‘dembol’
    # 200MB bandwidth limit for user ‘dembol’
    # 限制用户流量为200MB
    CBandUserLimit 200000
    # redirect to [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    # 如果用户超出限制,跳转到URL[/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    CBandUserExceededURL [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # user's scoreboard file
    # 用户的scoreboard文件
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard
   
    # a period of time after which the scoreboard will be cleared (5 weeks)
    # (only in >=0.9.5-rc2)
    # 清空scoreboard的周期
    CBandUserPeriod 5W
--------------------------------------------------------------------------------
# assign virtualhost ‘xyz.org’ to user ‘dembol’
# 将虚拟主机‘xyz.org’分配给‘dembol’用户
    ServerName xyz.org
    # Specify virtualhost's owner
    # 指定虚拟主机的所有者
    CBandUser dembol
# assign virtualhost ‘aga.org’ to user ‘dembol’
# 将虚拟主机‘aga.org’分配给‘dembol’用户
    ServerName aga.org
    # Specify virtualhost's owner
    # 指定虚拟主机的所有者
    CBandUser dembol

per-user and per-virtualhost bandwidth limiting configuration (only in versions >=0.9.1)
按用户和虚拟主机混合方式指定流量和带宽(仅限于0.9.1之后版本)

In versions >=0.9.1 you can also mix per-user and per-virtualhost bandwidth limiting techniques
在0.9.1版之后,你可以混合用户和虚拟主机方式来指定流量和带宽
--------------------------------------------------------------------------------
# define user "dembol"
# 定义用户 “dembol”
    # 200MB bandwidth limit for user "dembol"
    # “dembol”用户流量限制为200MB
    CBandUserLimit 200000
    # redirect to [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    # 如果超出限制,跳转到URL[/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    CBandUserExceededURL [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # user's scoreboard file
    # 用户的scoreboard文件
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard
   
    # a period of time after which the scoreboard will be cleared (4 days)
    # (only in >=0.9.5-rc2)
    # 清空scoreboard的周期(4天)
    CBandUserPeriod 4D

--------------------------------------------------------------------------------
# assign virtualhost "xyz.org" to user "dembol"
# 将虚拟主机“xyz.org”分配给用户“dembol”
    ServerName xyz.org
    # Specify virtualhost's owner
    # 指定虚拟主机的所有者
    CBandUser dembol
   
    # 100MB virtualhost bandwidth limit
    # 限制此虚拟主机流量为100MB
    CBandLimit 100000
    # redirect to [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    # 如果超出限制,跳转到URL[/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    CBandExceededURL [/url][url=http://abc.org/bandwidth_exceeded.html]http://abc.org/bandwidth_exceeded.html
    # virtualhost's scoreboard file
    # 虚拟主机的scoreboard文件
    CBandScoreboard /var/run/apache2/xyz.org.scoreboard
   
    # a period of time after which the scoreboard will be cleared (50 minutes)
    # (only in >=0.9.5-rc2)
    # 清空scoreboard的周期(50分钟)
    CBandPeriod 50M
# assign virtualhost "aga.org" to user "dembol"
# 将虚拟主机“aga.org”分配给用户“dembol”
    ServerName aga.org
    # Specify virtualhost's owner
    # 指定虚拟主机的所有者
    CBandUser dembol
per-destination bandwidth limiting configuration (only in >=0.9.5-rc1 versions)
按远程目标指定流量和带宽(仅限0.9.5-rc1之后版本)In >= 0.9.5-rc1 you can limit traffic to some destination classes. The destination classes are defined by  section. The limits for the classes are specified by CBandClassLimit and CBandUserClassLimit commands
在0.9.5-rc1之后,你可以通过来定义远程目标类来指定类的流量和带宽。同时也可以定义CBandClassLimit和CBandUserClassLimit来定义不同的类
# define "class_1"
# 定义 "class_1"
    CBandClassDst 217.172.231.67
    CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
    CBandClassDst 10.0.0.20
# define "class_2"
# 定义"class_2"
    CBandClassDst 192.168.100.100
    CBandClassDst 153.19/16
    CBandUserLimit 1000000
    CBandUserExceededURL [/url][url=http://edns.pl/bandwidth_exceeded.html]http://edns.pl/bandwidth_exceeded.html
    CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard
    # 500MB limit for "class_2"
    # "class_2"限制流量500MB
    CBandUserClassLimit class_2 500000
    CBandUser dembol
    # 1GB limit for "class_1"
    # "class_1"限制流量1GB
    CBandClassLimit class_1 1000000
    # a period of time after which the scoreboard will be cleared (120 seconds)
    # (only in >=0.9.5-rc2)
    # 定义scoreboard的清空时间为120秒(仅限0.9.5-rc2以上版本)
    CBandPeriod 120S

Configuration file example
配置文件实例
    # 可以通过[/url][url=http://yourdomain/cband-status]http://yourdomain/cband-status查看流量
   
    SetHandler cband-status
   
   
    # 超出限制,跳转到google
    CBandDefaultExceededURL [/url][url=http://www.google.com/]http://www.google.com
    # 定义类别
   
    CBandClassDst 217.172.231.67
    CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
    CBandClassDst 10.0.0.20
   

   
    CBandClassDst 192.168.100.100
    CBandClassDst 153.19/16
   

   
    CBandClassDst 10.13/16
   
   
    # 定义用户
   
    CBandUserLimit 100000
    CBandUserExceededURL http://server_name.com/bandwidth_exceeded.html
    CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard
    CBandUserPeriod 10W
   

   
    CBandUserLimit 1000000
    CBandUserExceededURL [/url][url=http://server_name.com/bandwidth_exceeded.html]http://server_name.com/bandwidth_exceeded.html 
    CBandUserScoreboard /home/dembol/write/user.dembolek.scoreboard
    CBandUserClassLimit class_1 50000
    CBandUserPeriod 20H
   

   
    CBandUserLimit 10000000
    CBandUserExceededURL [/url][url=http://www.google.com/]http://www.google.com
    CBandUserScoreboard /home/dembol/write/user.dembol.nasa.pl.scoreboard
    CBandUserClassLimit class_2 3000
    CBandUserClassLimit class_3 10000
    CBandUserPeriod 2H
   

NameVirtualHost *:80
DocumentRoot /home/dembol/public_html/dembol.nasa.pl/
ServerName dembol.nasa.pl
ServerAlias *.dembol.nasa.pl
Setenv VLOG /home/dembol/public_html/logs/dembol.nasa.pl.access
CustomLog /home/dembol/public_html/logs/dembol.nasa.pl.access combined
ErrorLog /home/dembol/public_html/logs/dembol.nasa.pl.error
# 设定虚拟主机的cband
    CBandLimit 100000000
    CBandUser dembol.nasa.pl
    CBandExceededURL [/url][url=http://edns.pl/bandwidth_exceeded.html]http://edns.pl/bandwidth_exceeded.html
    CBandScoreboard /home/dembol/write/dembol.nasa.pl.scoreboard
    CBandClassLimit class_1 10000000
    CBandPeriod 200S

DocumentRoot /home/dembol/public_html/dembol.nasa.pl/
ServerName dembol.eu.orgServerAlias *.dembol.eu.org
Setenv VLOG /home/dembol/public_html/logs/dembol.eu.org.access
CustomLog /home/dembol/public_html/logs/dembol.eu.org.access combined
ErrorLog /home/dembol/public_html/logs/dembol.eu.org.error
# 设定虚拟主机的cband
    CBandUser dembolek
    CBandLimit 10000
    CBandExceededURL [/url][url=http://server_name.com/bandwidth_exceeded.html]http://server_name.com/bandwidth_exceeded.html
    CBandScoreboard /home/dembolek/write/dembol.eu.org.scoreboard
    CBandClassLimit class_1 700000
    CBandClassLimit class_2 100000
    CBandClassLimit class_3 500000
    CBandPeriod 5D

DocumentRoot /home/dembol/public_html/dembol.nasa.pl/cvs_alias
ServerName cvs.cband.linux.pl:80
Setenv VLOG /home/dembol/public_html/logs/cvs.cband.linux.pl.access
CustomLog /home/dembol/public_html/logs/cvs.cband.linux.pl.access combined
ErrorLog /home/dembol/public_html/logs/cvs.cband.linux.pl.error
# 设定虚拟主机的cband
    CBandUser dembol
    CBandLimit 100000
    CBandExceededURL [/url][url=http://server_name.com/bandwidth_exceeded.html]http://server_name.com/bandwidth_exceeded.html
    CBandScoreboard /home/dembol/write/dembol.eu.org.scoreboard
    CBandClassLimit class_3 20000
    CBandPeriod 1W

Performance Tests
性能测试mod_cband without CBandScoreFlushPeriod directive
mod_cband 不清空score
MPM preforkMPM workerMPM perchildMPM eventMPM leaderwith mod_cband316.63 rps346.89 rps~297.36 rps~without mod_cband447.76 rps406.91 rps~425.13 rps~mod_cband with CBandScoreFlushPeriod 100 directive
mod_cband 设定清空score周期为100
MPM preforkMPM workerMPM perchildMPM eventMPM leaderwith mod_cband405.17 rps365.22 rps~414.60 rps~without mod_cband447.76 rps406.91 rps~425.13 rps~Http server: Apache 2.2, default http.conf, compiled with:
Apache2.2版,默认的http.conf配置,按以下方式编译
./configure --with-mpm=$1 \
  --enable-layout=Slackware \
  --enable-v4-mapped \
  --enable-cache \
  --enable-disk-cache --enable-mem-cache \
  --enable-deflate \
  --enable-ssl \
  --enable-mods-shared=all \
  --with-uid=apache --with-gid=apache \
  --with-gdbm --with-berkeley-db
Linux kernel: 2.6.14.2-grsec
Linux 内核版本:2.6.14.2-grsec
Machine: 2xPentium II 333MHz, 320MB RAM
机器配置:双PII 333MHz,320MB内存
Network: 100Mbps ethernet
网络:100Mbps以太网
Test command:
测试使用命令
httperf --server 192.168.0.25 --port 8 --num-conns 1000 --uri http://www.traktor.pl --hog
顶端 Posted: 2007-06-18 09:07 | [楼 主]
admin
级别: 管理员


精华: 1
发帖: 4646
威望: 47 点
金钱: 23190 RMB
贡献值: 0 点
注册时间:2006-10-09
最后登录:2008-12-01

 

                mod_cband - A per-user, per-virtualhost and per-destination bandwidth
                            limiter for the Apache HTTP Server Version 2
                        
                        
                         Documentation
                         =============


1. Units accepted in various directives:

    * transfer speeds:
          o kbps, Mbps, Gbps - multiples of "bits per second", respectively: 1024, 1024*1024 and 1024*1024*1024 bps
          o kb/s, Mb/s, Gb/s - multiples of "bytes per second", respectively: 1024, 1024*1024 and 1024*1024*1024 b/s
          o defaults to kbps

    * transfer quotas:
          o K, M, G - multiples of bytes, respectively: 1000, 1000*1000 and 1000*1000*1000 bytes
          o Ki, Mi, Gi - multiples of bytes, respectively: 1024, 1024*1024 and 1024*1024*1024 bytes
          o defaults to K

    * time periods:
          o S, M, H, D, W - multiples of seconds: Seconds, Minutes, Hours, Days, Weeks; respectively: 1, 60, 3600, 86400, 604800 seconds
          o defaults to S


2. Directives

Name        CBandDefaultExceededURL
Description     Default URL where mod_cband should redirect all requests to the virtualhost or
        user when the configured transfer limit is exceeded
NOTE:        If you don't specify the exceeded URL location then standard 503 Service Unavailable
        will be sent
Context     Server config
Syntax         CBandDefaultExceededURL URL


Name         CBandDefaultExceededCode
Description     The http code sent to the user when the configured transfer is exceeded
Context     Server config
Syntax         CBandDefaultExceededCode HTTP_CODE
Example     CBandDefaultExceededCode 509


Name         CBandScoreFlushPeriod
Description     Specifies a period after which the score for the virtualhost or user is written to the scoreboard file. Use this to improve mod_cband's performance
Default     1
Context     Server config
Syntax         CBandScoreFlushPeriod number_of_requests
Example     CBandScoreFlushPeriod 100
        Any virtualhost's or user's scoreboard will be saved after 100 requests


Name         CBandSpeed
Description     Specifies a maximal speed for a virtualhost
Context     <Virtualhost>
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


Name         CBandRemoteSpeed
Description     Specifies maximal speed for any remote client
Context     <Virtualhost>
Syntax         CBandRemoteSpeed 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     CBandRemoteSpeed 20kb/s 3 3
        Specifies maximal speed 20kB/s (20 * 1024 bytes per second),
        maximal 3 requests per second and 3 open connections for any remote client
NOTE:        This feature is available from version 0.9.6.1-rc2


Name         CBandClassRemoteSpeed
Description     Specifies maximal speed for any remote client from some destination class
Context     <Virtualhost>
Syntax         CBandClassRemoteSpeed class_name kbps rps
        class_name - name of defined destination class
        kbps - maximal transfer speed in kbps or kB/s
        rps - maximal requests per second
        max_conn - maximal number of simultaneous connections
Example     <CBandClass googlebot_class>
           CBandClassDst 66.249.64/24
           CBandClassDst 66.249.65/24
           CBandClassDst 66.249.79/24
        </CBandClass>
        CBandClassRemoteSpeed googlebot_class 20kb/s 2 3
       
        Specifies maximal speed 20kB/s (20 * 1024 bytes per second),
        maximal 2 requests per second and 3 open connections for any remote client from
        class googlebot_class
NOTE:        This feature is available from version 0.9.6.1-rc2


Name         CBandRandomPulse
Description     Turns On or Off the random pulse generator for data sending
        Random pulse generator is a part of the speed-limiting implementation of mod_cband.
        This directive changes the way a connection's speed is determined and enforced.
        The connections' speeds are measured within some time period and then provided for in
        that period. When r.p.g. is enabled this period is chosen randomly,
        providing for a statisticaly saner load distribution. Disabling this causes spikes both in
        bandwidth and cpu usages
Context     Global
Syntax         CBandRandomPulse On/Off


Name         CBandLimit
Description     Specifies bandwidth limit for virtualhost
Context     <Virtualhost>
Syntax         CBandLimit limit
        limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
        Mi (mebi), Gi (gibi)
Example     CBandLimit 10M
        Specifies 10 * 1000 * 1000 bytes bandwidth quota

        CBandLimit 10Mi
        Specifies 10 * 1024 * 1024 bytes bandwidth quota


Name         CBandClassLimit
Description     Specifies bandwidth limit for virtualhost's destination class
Context     <Virtualhost>
Syntax         CBandClassLimit class_name limit
        class_name - the name of defined class
        limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
        Mi (mebi), Gi (gibi)


Name         CBandExceededURL
Description     Specifies a URL where mod_cband should redirect all requests to a virtualhost when the configured transfer limit is exceeded NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context     <Virtualhost>
Syntax         CBandExceededURL URL


Name         CBandExceededSpeed
Description     Specifies maximal speed to which mod_cband slows down a virtualhost when the configured transfer limit is exceeded
Context     <Virtualhost>
Syntax         CBandExceededSpeed kbps rps max_conn
        kbps - maximal transfer speed in kbps or kB/s
        rps - maximal requests per second
        max_conn - maximal number of simultaneous connections
NOTE:        This feature is available from version 0.9.6.0


Name         CBandScoreboard
Description     Specifies virtualhost's scoreboard file
Context     <Virtualhost>
Syntax         CBandScoreboard path
NOTE:         The path must be writeable for the apache-user


Name         CBandPeriod
Description     Specifies a period after which a virtualhost's usages are cleared
Context     <Virtualhost>
Syntax         CBandPeriod period
        period - available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
Example     CBandPeriod 1W
        CBandPeriod 14D
        CBandPeriod 60M
       
       
Name         CBandPeriodSlice
Description     Specifies the period slice length
Default     slice_len = limit
Context     <Virtualhost>
Syntax         CBandPeriodSlice slice_length
Example     CBandLimit 100G
        CBandPeriod 4W
        CBandPeriodSlice 1W
        A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G
        bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G ...


Name         <CBandUser>
Description     Define a new cband user
Context     Server config
Syntax         <CBandUser user_name>


Name         CBandUserSpeed
Description     Specifies maximal speed for a cband user
Context     <CBandUser>
Syntax         CBandUserSpeed kbps rps max_conn
        kbps - maximal transfer speed in kbps or kB/s
        rps - maximal requests per second
        max_conn - maximal number of simultaneous connections
Example     CBandUserSpeed 100kb/s 10 5
        Specifies maximal speed 100 kB/s (100 * 1024 bytes per second),
        maximal 10 requests per second and 5 open connections
NOTE:        This feature is available from version 0.9.6.0


Name         CBandUserLimit
Description     Specifies bandwidth limit for a cband user
Context     <CBandUser>
Syntax         CBandUserLimit limit
        limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
        Mi (mebi), Gi (gibi)
Example     CBandUserLimit 10M
        Specifies 10 * 1000 * 1000 bytes bandwidth quota

        CBandUserLimit 10Mi
        Specifies 10 * 1024 * 1024 bytes bandwidth quota


Name         CBandUserClassLimit
Description     Specifies bandwidth limit for a cband user's destination class
Context     <CBandUser>
Syntax         CBandUserClassLimit class_name limit
        class_name - the name of defined class
        limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
        Mi (mebi), Gi (gibi)


Name         CBandUserExceededURL
Description     Specifies a URL where mod_cband should redirect all requests to user's virtualhost when the configured transfer limit is exceeded
NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context     <CBandUser>
Syntax         CBandUserExceededURL URL


Name         CBandUserExceededSpeed
Description     Specifies maximal speed to which mod_cband slows down user when the configured transfer limit is exceeded
NOTE:         CBandUserExceededURL must not be used if you want to only slow down user's pages with
        CBandUserExceededSpeed directive
Context     <CBandUser>
Syntax         CBandUserExceededSpeed kbps rps max_conn
        kbps - maximal transfer speed in kbps or kB/s
        rps - maximal requests per second
        max_conn - maximal number of simultaneous connections
NOTE:        This feature is available from version 0.9.6.0


Name         CBandUserScoreboard
Description     Specifies a user's scoreboard file
Context     <CBandUser>
Syntax         CBandUserScoreboard path
NOTE:         The path must be writeable for the apache-user


Name         CBandUserPeriod
Description     Specifies a period after which a user's usages are cleared
Context     <CBandUser>
Syntax         CBandUserPeriod period
        period - available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
Example     CBandUserPeriod 1W
        CBandUserPeriod 14D
        CBandUserPeriod 60M
       
       
Name         CBandUserPeriodSlice
Description     Specifies a period slice length
Default     slice_len = limit
Context     <CBandUser>
Syntax         CBandUserPeriodSlice slice_length
Example     CBandUserLimit 100G
        CBandUserPeriod 4W
        CBandUserPeriodSlice 1W
        A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G
        bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G ...


3. Status Handler Configuration Example
To view actual bandwidth limits, usages, users, scoreboards, add the following lines into the config file:

<Location /cband-status>
SetHandler cband-status
</Location>

<Location /cband-status-me>
SetHandler cband-status-me
</Location>

Then you can access the status page with a URL like:
http://server_name/cband-status
http://server_name/cband-status-me

An example of the cband-status is available here
An example of the cband-status-me is available here

In versions >=0.9.5-rc1 you can also view /cband-status handler in the XML format:

http://server_name/cband-status?xml
http://server_name/cband-status-me?xml

An example of the cband-status in the XML format is available here
An example of the cband-status-me in the XML format is available here


4. Bandwidth Speed Configuration Example

<VirtualHost *:80>
    DocumentRoot /var/www/xyz.org/
    ServerName xyz.org
    CustomLog /var/log/apache2/xyz.org.access combined
    ErrorLog /var/log/apache2/xyz.org.access.error
    RewriteEngine On
    RewriteOptions inherit

    # Maximal 1024kbps speed for this virtualhost
    # Maximal 10 requests per second for this virtualhost
    # Maximal 30 open connections for this virtualhost
    CBandSpeed 1024 10 30
   
    # Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client
    CBandRemoteSpeed 10kb/s 3 2
   
    # Maximal 20kB/s speed, 2 requests/s and 3 open connections for remote
    # clients from class googlebot_class :P
    CBandClassRemoteSpeed googlebot_class 20kb/s 2 3
</VirtualHost>

5. Bandwidth Quota Configuration Example
per-virtualhost bandwidth limiting configuration
Next, you may define virtualhost's bandwidth limits, URL location and the path to scoreboard files for individual virtualhosts:

# specify default 'bandwidth exceeded' location
CBandDefaultExceededURL    http://haha.org/bandwidth_exceeded.html

<VirtualHost *:80>
    DocumentRoot /var/www/xyz.org/
    ServerName xyz.org
    CustomLog /var/log/apache2/xyz.org.access combined
    ErrorLog /var/log/apache2/xyz.org.access.error
    RewriteEngine On
    RewriteOptions inherit

    # 100MB virtualhost bandwidth limit
    CBandLimit 100000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandExceededURL http://abc.org/bandwidth_exceeded.html

    # virtualhost's scoreboard file
    CBandScoreboard /var/run/apache2/xyz.org.scoreboard
   
    # a period of time after which the scoreboard will be cleared (30 minutes)
    # (only in >=0.9.5-rc2)
    CBandPeriod 30M
</VirtualHost>


per-user bandwidth limiting configuration (only in versions >=0.9.1)
In versions >=0.9.1 you can define limits for users and assign virtualhosts to them

# define user 'dembol'
<CBandUser dembol>
    # 200MB bandwidth limit for user 'dembol'
    CBandUserLimit 200000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandUserExceededURL http://abc.org/bandwidth_exceeded.html

    # user's scoreboard file
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard
   
    # a period of time after which the scoreboard will be cleared (5 weeks)
    # (only in >=0.9.5-rc2)
    CBandUserPeriod 5W
</CBandUser>

# assign virtualhost 'xyz.org' to user 'dembol'
<VirtualHost *:80>
    ServerName xyz.org
    # Specify virtualhost's owner
    CBandUser dembol
</VirtualHost>

# assign virtualhost 'aga.org' to user 'dembol'
<VirtualHost *:80>
    ServerName aga.org
    # Specify virtualhost's owner
    CBandUser dembol
</VirtualHost>


per-user and per-virtualhost bandwidth limiting configuration (only in versions >=0.9.1)
In versions >=0.9.1 you can also mix per-user and per-virtualhost bandwidth limiting techniques

# define user 'dembol'
<CBandUser dembol>
    # 200MB bandwidth limit for user 'dembol'
    CBandUserLimit 200000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandUserExceededURL http://abc.org/bandwidth_exceeded.html

    # user's scoreboard file
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard
   
    # a period of time after which the scoreboard will be cleared (4 days)
    # (only in >=0.9.5-rc2)
    CBandUserPeriod 4D
</CBandUser>

# assign virtualhost 'xyz.org' to user 'dembol'
<VirtualHost *:80>
    ServerName xyz.org
    # Specify virtualhost's owner
    CBandUser dembol
   
    # 100MB virtualhost bandwidth limit
    CBandLimit 100000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandExceededURL http://abc.org/bandwidth_exceeded.html

    # virtualhost's scoreboard file
    CBandScoreboard /var/run/apache2/xyz.org.scoreboard
   
    # a period of time after which the scoreboard will be cleared (50 minutes)
    # (only in >=0.9.5-rc2)
    CBandPeriod 50M
</VirtualHost>

# assign virtualhost 'aga.org' to user 'dembol'
<VirtualHost *:80>
    ServerName aga.org
    # Specify virtualhost's owner
    CBandUser dembol
</VirtualHost>


per-destination bandwidth limiting configuration (only in >=0.9.5-rc1 versions)
In >= 0.9.5-rc1 you can limit traffic to some destination classes. The destination classes are defined by <CBandClass class_name> section. The limits for the classes are specified by CBandClassLimit and CBandUserClassLimit commands

# define 'class_1'
<CBandClass class_1>
    CBandClassDst 217.172.231.67
    CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
    CBandClassDst 10.0.0.20
</CBandClass>

# define 'class_2'
<CBandClass class_2>
    CBandClassDst 192.168.100.100
    CBandClassDst 153.19/16
</CBandClass>

<CBandUser dembol>
    CBandUserLimit 1000000
    CBandUserExceededURL http://edns.pl/bandwidth_exceeded.html
    CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard
   
    # 500MB limit for 'class_2'
    CBandUserClassLimit class_2 500000
</CBandUser>

<VirtualHost *:80>
    ...
    CBandUser dembol
   
    # 1GB limit for 'class_1'
    CBandClassLimit class_1 1000000
   
    # a period of time after which the scoreboard will be cleared (120 seconds)
    # (only in >=0.9.5-rc2)
    CBandPeriod 120S
</VirtualHost>
顶端 Posted: 2007-06-18 09:20 | 1 楼
admin
级别: 管理员


精华: 1
发帖: 4646
威望: 47 点
金钱: 23190 RMB
贡献值: 0 点
注册时间:2006-10-09
最后登录:2008-12-01

 

<IfModule mod_cband.c>
    <Location /cband-status>
    SetHandler cband-status
    </Location>

    CBandDefaultExceededURL http://www.google.com

    <CBandClass class_1>
    CBandClassDst 217.172.231.67
        CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
        CBandClassDst 10.0.0.20
    </CBandClass>

    <CBandClass class_2>
    CBandClassDst 192.168.100.100
        CBandClassDst 153.19/16
    </CBandClass>

    <CBandClass class_3>
    CBandClassDst 10.13/16
    </CBandClass>

    <CBandUser dembol>
    CBandUserLimit 100M
        CBandUserExceededURL http://server_name.com/bandwidth_exceeded.html
    CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard
    CBandUserPeriod 10W
    </CBandUser>

    <CBandUser dembolek>
        CBandUserLimit 1000000
    CBandUserExceededURL http://server_name.com/bandwidth_exceeded.html
        CBandUserScoreboard /home/dembol/write/user.dembolek.scoreboard
    CBandUserClassLimit class_1 50000
    CBandUserPeriod 20H
    </CBandUser>

    <CBandUser dembol.nasa.pl>
        CBandUserLimit 1G
    CBandUserExceededURL http://www.google.com
        CBandUserScoreboard /home/dembol/write/user.dembol.nasa.pl.scoreboard
    CBandUserClassLimit class_2 3000K
        CBandUserClassLimit class_3 100M
    CBandUserPeriod 2H
    </CBandUser>
</IfModule>

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /home/dembol/public_html/dembol.nasa.pl/
ServerName dembol.nasa.pl
ServerAlias *.dembol.nasa.pl
Setenv VLOG /home/dembol/public_html/logs/dembol.nasa.pl.access
CustomLog /home/dembol/public_html/logs/dembol.nasa.pl.access combined
ErrorLog /home/dembol/public_html/logs/dembol.nasa.pl.error
<IfModule mod_cband.c>
    CBandLimit 600M
    CBandUser dembol.nasa.pl
    CBandExceededURL http://edns.pl/bandwidth_exceeded.html
    CBandScoreboard /home/dembol/write/dembol.nasa.pl.scoreboard
    CBandClassLimit class_1 1G
    CBandPeriod 200S
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/dembol/public_html/dembol.nasa.pl/
ServerName dembol.eu.org
ServerAlias *.dembol.eu.org
Setenv VLOG /home/dembol/public_html/logs/dembol.eu.org.access
CustomLog /home/dembol/public_html/logs/dembol.eu.org.access combined
ErrorLog /home/dembol/public_html/logs/dembol.eu.org.error
<IfModule mod_cband.c>
    CBandUser dembolek
    CBandLimit 900M
    CBandExceededURL http://server_name.com/bandwidth_exceeded.html
    CBandScoreboard /home/dembolek/write/dembol.eu.org.scoreboard
    CBandClassLimit class_1 700M
    CBandClassLimit class_2 100000
    CBandClassLimit class_3 5000K
    CBandPeriod 5D
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/dembol/public_html/dembol.nasa.pl/cvs_alias
ServerName cvs.cband.linux.pl:80
Setenv VLOG /home/dembol/public_html/logs/cvs.cband.linux.pl.access
CustomLog /home/dembol/public_html/logs/cvs.cband.linux.pl.access combined
ErrorLog /home/dembol/public_html/logs/cvs.cband.linux.pl.error
<IfModule mod_cband.c>
    CBandUser dembol
    CBandLimit 10G
    CBandExceededURL http://server_name.com/bandwidth_exceeded.html
    CBandScoreboard /home/dembol/write/dembol.eu.org.scoreboard
    CBandClassLimit class_3 200M
    CBandPeriod 1W
</IfModule>
</VirtualHost>
顶端 Posted: 2007-06-18 09:22 | 2 楼
admin
级别: 管理员


精华: 1
发帖: 4646
威望: 47 点
金钱: 23190 RMB
贡献值: 0 点
注册时间:2006-10-09
最后登录:2008-12-01

 

<IfModule mod_cband.c>
    <Location /cband-status>
    SetHandler cband-status
    </Location>

    CBandDefaultExceededURL http://www.google.com
    CBandScoreFlushPeriod 100

    <CBandClass class_1>
    CBandClassDst 216.239.37.99
        CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
        CBandClassDst 10.0.0.20
    </CBandClass>

    <CBandClass class_2>
    CBandClassDst 192.168.100.100
        CBandClassDst 153.19/16
    </CBandClass>

    <CBandClass class_3>
    CBandClassDst 10.13/16
    </CBandClass>

    <CBandUser user1>
    CBandUserLimit 100M
        CBandUserExceededURL http://myserver.com/exu1.html
    CBandUserScoreboard /var/run/apache2/scoreboards/user1.scoreboard
    CBandUserPeriod 10W
    </CBandUser>

    <CBandUser user2>
        CBandUserLimit 1000000
    CBandUserExceededURL http://myserver.com/exu2.html
        CBandUserScoreboard /var/run/apache2/scoreboards/user2.scoreboard
    CBandUserClassLimit class_1 50000
    CBandUserPeriod 20H
    </CBandUser>

    <CBandUser user3>
        CBandUserLimit 1G
    CBandUserExceededURL http://myserver.com/exu3.html
        CBandUserScoreboard /var/run/apache2/scoreboards/user3.scoreboard
    CBandUserClassLimit class_2 3000K
        CBandUserClassLimit class_3 100M
    CBandUserPeriod 2H
    CBandUserSpeed 512 10 10
    </CBandUser>
</IfModule>

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www2/html-vhost1
ServerName vhost1.myserver.com
<IfModule mod_cband.c>
    CBandLimit 600M
    CBandUser user1
    CBandExceededURL http://myserver.com/ex1.html
    CBandScoreboard /var/run/apache2/scoreboards/vhost1.scoreboard
    CBandClassLimit class_1 1G
    CBandPeriod 200S
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www2/html-vhost2
ServerName vhost2.myserver.com
<IfModule mod_cband.c>
    CBandUser user2
    CBandLimit 900M
    CBandExceededURL http://myserver.com/ex2.html
    CBandScoreboard /var/run/apache2/scoreboards/vhost2.scoreboard
    CBandClassLimit class_1 700M
    CBandClassLimit class_2 100000
    CBandClassLimit class_3 5000K
    CBandPeriod 5D
    CBandSpeed 1000 10 10
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www2/html-vhost3
ServerName vhost3.myserver.com
<IfModule mod_cband.c>
    CBandUser user3
    CBandLimit 10G
    CBandExceededURL http://myserver.com/ex3.htm
    CBandScoreboard /var/run/apache2/scoreboards/vhost3.scoreboard
    CBandClassLimit class_3 200M
    CBandPeriod 1W
    CBandSpeed 2000 10 10
</IfModule>
</VirtualHost>
顶端 Posted: 2007-06-18 09:23 | 3 楼
admin
级别: 管理员


精华: 1
发帖: 4646
威望: 47 点
金钱: 23190 RMB
贡献值: 0 点
注册时间:2006-10-09
最后登录:2008-12-01

 

# Speed limiting example

<IfModule mod_cband.c>

    # Turn On random pulse for data sending
    CBandRandomPulse On
   
    <Location /cband-status>
    SetHandler cband-status
    </Location>

    CBandDefaultExceededURL http://www.google.com
    CBandScoreFlushPeriod 100

    <CBandClass class_1>
    CBandClassDst 216.239.37.99
        CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
        CBandClassDst 10.0.0.20
    </CBandClass>

    <CBandClass class_2>
    CBandClassDst 192.168.100.100
        CBandClassDst 153.19/16
    </CBandClass>

    <CBandClass class_3>
    CBandClassDst 10.13/16
    </CBandClass>

    <CBandUser user1>
    CBandUserLimit 100M
        CBandUserExceededURL http://myserver.com/exu1.html
    CBandUserScoreboard /var/run/apache2/scoreboards/user1.scoreboard
    CBandUserPeriod 10W
   
    # 1024kbps, 10 request/s, max 10 connections
    CBandUserSpeed 1024 10 10
    </CBandUser>

    <CBandUser user2>
        CBandUserLimit 1000000
    CBandUserExceededURL http://myserver.com/exu2.html
        CBandUserScoreboard /var/run/apache2/scoreboards/user2.scoreboard
    CBandUserClassLimit class_1 50000
    CBandUserPeriod 20H
    </CBandUser>

    <CBandUser user3>
        CBandUserLimit 1G
    CBandUserExceededURL http://myserver.com/exu3.html
        CBandUserScoreboard /var/run/apache2/scoreboards/user3.scoreboard
    CBandUserClassLimit class_2 3000K
        CBandUserClassLimit class_3 100M
    CBandUserPeriod 2H
    # 512kbps, 10 requests/s, max 10 connections
    CBandUserSpeed 512 10 10
    </CBandUser>
</IfModule>

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www2/html-vhost1
ServerName vhost1.myserver.com
<IfModule mod_cband.c>
    CBandLimit 600M
    CBandUser user1
    CBandExceededURL http://myserver.com/ex1.html
    CBandScoreboard /var/run/apache2/scoreboards/vhost1.scoreboard
    CBandClassLimit class_1 1G
    CBandPeriod 200S
   
    # 100kb/s, 10 request/s, max 5 connections
    CBandSpeed 100kb 10 5
   
    # 10kb/s, 3 request/s -> speed limit for any remote client, max 5 connections
    CBandRemoteSpeed 10kb/s 3 5
   
    # 10kb/s, 2 request/s -> speed limit for remote client from class_2, max 5 connections
    CBandClassRemoteSpeed class_2 10kb/s 2 5
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www2/html-vhost2
ServerName vhost2.myserver.com
<IfModule mod_cband.c>
    CBandUser user2
    CBandLimit 900M
    CBandExceededURL http://myserver.com/ex2.html
    CBandScoreboard /var/run/apache2/scoreboards/vhost2.scoreboard
    CBandClassLimit class_1 700M
    CBandClassLimit class_2 100000
    CBandClassLimit class_3 5000K
    CBandPeriod 5D
    CBandSpeed 1000 10 10
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www2/html-vhost3
ServerName vhost3.myserver.com
<IfModule mod_cband.c>
    CBandUser user3
    CBandLimit 10G
    CBandExceededURL http://myserver.com/ex3.htm
    CBandScoreboard /var/run/apache2/scoreboards/vhost3.scoreboard
    CBandClassLimit class_3 200M
    CBandPeriod 1W
    CBandSpeed 2000 10 10
</IfModule>
</VirtualHost>
顶端 Posted: 2007-06-18 09:23 | 4 楼
帖子浏览记录 版块浏览记录
承德互联 » unix专区

Total 0.043652(s) query 7, Time now is:12-02 06:17, Gzip enabled
Powered by PHPWind v6.3.2 Certificate Code © 2003-08 PHPWind.com Corporation