Squid  - 延迟池带宽管理

Squid - 延迟池带宽管理

此功能用于限制用户社区的带宽使用。 它已经在版本2.x中引入。

使用延迟池实现带宽管理

“延迟池有3个不同的限制类”

1. 1级池可以限制大量下载带宽的速率。

这使得限制大文件的下载速率。

实现Class1延迟池

脚步:

  1. 定义延迟池的ACL
  2. 定义延迟池的数量(delay_pools 1)
  3. 定义延迟池类(delay_calss 1 1)
  4. 设置池号的参数(delay_parameres 1 restore_rate / max_size)。 一旦请求超出了max_size,则squid将使带宽达到用户/源的给定restore_rate(测量采用“bytes”),例如: - delay_parameters 1 20000/15000
  5. 启用delay_access以包含该功能(delay_access)

配置1类延迟池:

# vim squid.conf
acl    bw_users    src    192.168.1.0/24      # The acl defined for the Network    
delay_pools    1                                         # This will tell the delay pool number
delay_calss    1 1                                       # This defines the delay pool number 1 is a class1 type delay pool
delay_parameters    1    20000/15000        #This is delay parameter for pool number 1 which has the restore rate of 20000 when the usage hits 15000 bytes
delay_access    1    allow    bw_users      # This is the access tag which tie to the acl bw_users

#重新加载Squid

这将使src中的任何一个的带宽使用,当下载限制为15K时,将下载速率恢复到20K / s。

使用wget下载文件来测试配置。

class pool1的限制:如果我们的带宽为1500000字节,如果我们配置每秒20000字节的速率,则最大同时连接将为1500000/20000 = 75.如果我们有大量的来自src的连接。

2. 2级池允许将带宽使用率设置为持续速率

使用2级池,我们可以克服class1中的max的限制。 所以在这里我们可以实现总带宽带宽。

配置2类池:

如果我们拥有带宽为(1.5Mb / s)1544000字节/ s带宽的链路。

如果我们需要限制或设置62500字节/秒(500k / s)的上限作为网线的带宽和每个用户的上限的10%。

# vim squid.conf
acl    bw_users    src    192.168.1.0/24 # The acl defined for the Network
delay_pools    1                                    # Number of Pool
delay_class    1 2                                  # Defines the class of pool for the Pool Number 1
delay_parametes    1 62500/62500 6250/6250 # This tells to create a cieling of 500K (62500) for our bandwidth having (1.5M) with a indivigual cieling of  #10% of the cieling (Any given time the users will be restricted to the 10% of the cieling bandwidth 500k)
delay_access  1  allow  bw_users        # This is the access tag which tie to the acl bw_users

#重新加载Squid

使用wget测试带宽速率。 在这里我们可以看到,所有的速度都将从一开始就被限制在所有src的10%。 这使得剩余的带宽可以用于其他目的,即在1.5M之外,我们已经对内网进行了1.5M的标识,并且我们已经告诉Squid,src的每个请求都应该获得0.5M的带宽。

在class1池中,限制带宽仅在满足最大下载大小后才启动。 但是在第2类而不是最大的下载大小这里我们定义了一个上限,用户从一开始就被限制在它上面。

3. Class3池允许限制子网的带宽使用

这将以每个子网的总速率来实现带宽管理。 即具有基于子网的天花板的class2池。

配置3级池:

# vim squid.conf
acl    bw_users    src    192.168.1.0/24 # The acl defined for the Network
delay_pools    1                                    # Number of Pool
delay_class    1 3                                 # Defines the class of pool for the Pool Number 1
delay_parametes    1 62500/62500 31250/31250 6250/6250 # This tells to create a cieling of 500K (62500) for our bandwidth having (1.5M) with a subnets cieling of 50% of the cieling (Any given time the request from the each subnets will be restricted to the 50% of the cieling bandwidth 500k and each users in subnet will have 20% of the bandwidth rate of subnet cieling)
delay_access  1  allow  bw_users       # This is the access tag which tie to the acl bw_users

#重新加载Squid

这使得Squid使每个子网的带宽使用率为50%(如果我们的网络中有2个子网,则为Incase),并且每个用户将获得子网cieling的20%。 (即在1.5M以内,我们已经采取了0.5M的子网,子网cieling将分享这个0.5M的(50M)的50%,在每个子网中,用户将获得20%(.5M)的带宽子网上限(.25M))。

延迟池类2与基于时间的ACL:

这将仅在工作时间内实施带宽管理。

配置时间限制的Class2池:

# vim squid.conf
acl    bw_users src 192.168.1.0/24         # The acl defined for the Network
acl work_time time MTWHF 09:00-18:00
delay_pools    1                                      # Number of Pool
delay_class    1 2                                    # Defines the class of pool for the Pool Number 1
delay_parametes    1 62500/62500 25000/25000 # each user has given an average of 25000 bytes of bandwidth
delay_access  1  allow work_time         # This is the access tag which tie to the acl all and work_time.

#重新加载Squid

这将使第2类池只在办公时间才被激活。 通过在配置具有时间段的类2池之后更改Squid服务器中的时间来进行测试。

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏