3

代理服务器 Cake 队列规则常用参数推荐

 1 year ago
source link: https://gist.github.com/liberal-boy/c2e414165206451532874ea0da1d15cd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

代理服务器 Cake 队列规则常用参数推荐

  • 注意,BBR 等基于延迟判断发送窗口的拥塞控制算法可能与 AQM 发生冲突!!!对于使用 BBR 的设备,fq 可能还是最好的选择。

为什么选用 Cake

Cake 使用主动队列管理(AQM)技术保持全局同步,可以控制延迟,有效利用宽带。同时它还可以保证每个主机,每个流公平的分享宽带。

使用 Cake 的条件

Cake 与 kernel 4.19 并入主线,因此使用 Cake 需要 kernel 和 iproute2 版本大于 4.19。如何确认 kernel 和 iproute2 版本,以及如何升级本文不做详细说明。

如何启用 Cake

以 root 身份执行命令 tc qdisc replace dev eth0 root cake,其中 eth0 是网络接口名。

常用参数推荐

Cake 的参数十分通俗易懂,默认参数也适用于大部分网络环境,但是根据情况设置更能有效利用宽带。这里介绍几个容易设置、正确设置有一定作用的参数。

  • unlimited (默认值):不限制宽带,多数情况下可以直接使用。
  • bandwidth RATE:指定宽带,设置为网络接口的额定宽带,以便 Cake 调节参数,某些情况下指定宽带可能会提高网络利用率。

往返延迟参数

  • rtt TIME(默认 100ms): 此参数用于给 AQM 嵌入拥塞信号,过小可能提前触发拥塞导致无法充分利用宽带,推荐略大于测试出的实际 rtt。

系统开销补偿参数

这个参数较难解释,但是正确设置有一定提升,对于大部分使用以太网接口的服务器,推荐使用 ethernet 预设值。

优先级队列参数

Cake 会根据服务分类字段将流量分成不同的 tins,并使用不同的队列规则

  • besteffort:关闭优先级队列,全部流量使用一个 tins,推荐使用于代理服务器,因为代理服务器发送的流量基本来自代理工具,没有分类,建立多个队列浪费性能。
  • 其他选项对于代理服务器没有必要,暂不做介绍。

如何设置推荐参数

以 root 身份执行命令

tc qdisc replace dev eth0 root cake rtt 50ms ethernet besteffort

  • eth0 :网络接口名
  • 50ms :设置为略大于本地到此服务器的往返延迟

如何持久化参数

用上面命令设置的参数重启网络接口就会被重制,可以按以下方法持久化参数,各占位符的定义同上述。

Debain 9+ / Ubuntu 18.04+

  1. 编辑 /etc/network/interfaces
  2. iface eth0 ... 下新建一行加入

post-up tc qdisc replace dev eth0 root cake rtt 50ms ethernet besteffort

RHEL 7 / CentOS 7

  1. 编辑或新建 /sbin/ifup-local
if [[ "$1" == "eth0" ]]
then
  /usr/sbin/tc qdisc replace dev eth0 root cake rtt 50ms ethernet besteffort
fi
  1. 确保 /sbin/ifup-local 有执行权限,以 root 身份执行命令 chmod +x /sbin/ifup-local

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK