For those in the dark about how to limit/prioritize streaming bandwidth for servers running PMS; here is a guide dictating my personal method.
An alternate method is described in this thread and only requires /sbin/tc.
**If you are streaming from a server w/o the necessary kernel modules for traffic control (usually a dedicated server), follow my thread at torrent-invites to re-compile your linux kernel and include the appropriate modules for linux QoS**
HTB.init is a shell script derived from CBQ.init that allows for easy setup of HTB-based traffic control on Linux. HTB (Hierachical Token Bucket) is a new queueing discipline which attempts to address the weaknesses of current CBQ implementation.
First, ensure that you have the iproute package installed & module-loading kernel support**
# yum install iproute
Download the 'htb.init' from sourceforge and stick this file into /etc/init.d/ . Next, create the directory for storing our traffic classes: /etc/sysconfig/htb
# wget http://sourceforge.net/projects/htbinit/files/HTB.init/0.8.5/htb.init-v0.8.5/download # mv htb.init-v0.8.5 /etc/init.d/htb.init # chmod 755 /etc/init.d/htb.init # mkdir /etc/sysconfig/htb && cd /etc/sysconfig/htb
3) Define our ethernet device
The first file we create, 'eth0', specifies which device we are to create traffic rules for
# vi eth0 DEFAULT=99 R2Q=200
The contents of this file are rather simple: The DEFAULT directive specifies which rule number (ie. 99) we'll default to when no other rules match and the bandwidth rate (set in next step(s) ) divided by R2Q gives us our quantum, which is the amount of bandwidth given to one class before servicing another class. The faster your available network connection, the larger your quantum can be. This is the configuration for my 100mbps link server.
4) Define our total bandwidth
# vi eth0-2.root RATE=100Mbit CEIL=100Mbit BURST=1Mbit
The default RATE is the minimum rate for the class (device eth0 in this case). The CEILing is the maximum rate for the class. Finally, the BURST rate is the maximum amount of bandwidth that can be sent through the hardware without moving on to service another class. It is recommended to set the RATE 'just below' your maximum bandwidth to prevent buffering performed by auxiliary network equipment, but here I have chosen the maximum throughput value of my box as I'm confident my datacenter has accounted for this already.
5) Creating our class rule(s)
# vi eth0-2:10.plex RATE=2Mbit CEIL=3Mbit PRIO=1 RULE=*:32400, LEAF=sf
The heart of this tutorial lies with the configuration of this particular rule file. I set my Plex (source port 32400) traffic to be given a minimum rate of 2Mbit, and a maximum of 3Mbit. This traffic also has the highest priority (1). WIth this configuration, each client can utilize 'Direct Play' and theoretically I can serve 30 clients at any given time.
*future amendments to this rule would be to explicitly exclude neutral outgoing traffic from PMS meta-agent queries
**Rules are specified with the pattern RULE=[[saddr[/prefix]][:port[/mask]],][daddr[/prefix]][:port[/mask]]
6) Creating our default rule
# vi eth0-2:99.dfl RATE=3Mbit CEIL=100Mbit PRIO=7 LEAF=sfq
7) Final configurations
# chkconfig --add htb.init # chkconfig htb.init on # service htb.init start
One quick way to check that QoS is working is to download a video from your PMS server via Plex/Web and if the download speed is within the threshold, then you've succeeded.