我有一个数字海洋服务器,用于服务RTMP和hls live streaming.Is,我可以将每个流的输出带宽限制在1 1mbps或1.5mpb。
我已经尝试过仙人掌,但它限制了整个服务器带宽,但我需要一些方法来限制带宽只适用于rtmp和hls流。
发布于 2021-11-04 14:33:17
就个人而言,我会使用cgroups + tc或iptables。
在我的服务器上,我使用了一个名为wondersharper https://github.com/magnific0/wondershaper/blob/master/wondershaper的工具
这会限制给定网络接口上的带宽/吞吐量。我的NGINX服务器是在一个虚拟网络接口上列出的,它的带宽是有限的。
ip link add br0 type bridge
ip link set br0 up另一种方法(但没有经过测试)是iptables和hashlimit扩展。
https://ipset.netfilter.org/iptables-extensions.man.html
哈希限制使用散列桶来表示一组连接的速率限制匹配(如极限匹配),使用单个iptables规则。分组可以按主机组(源和/或目标地址)和/或每个端口进行。它使您能够表示“每组每个时间的N个数据包”或“每秒钟N个字节”(参见下面的一些示例)。
#matching bytes per second flows exceeding 512kbyte/s
--hashlimit-mode srcip,dstip,srcport,dstport --hashlimit-above 512kb/s
#matching bytes per second hosts that exceed 512kbyte/s, but permit up to 1Megabytes without matching
--hashlimit-mode dstip --hashlimit-above 512kb/s --hashlimit-burst 1mb在研究ipbtable部分时,我发现
http://info.iet.unipi.it/~luigi/dummynet/
文件可以在这里找到:\
https://www.freebsd.org/cgi/man.cgi?query=ipfw&manpath=FreeBSD+9-current&format=html
不过那个看起来挺有趣的。
https://stackoverflow.com/questions/69737716
复制相似问题