4.2. Prioritizing Network Traffic
net_priosubsystem can be used to set network priorities for processes in cgroups. These priorities are then translated into Type Of Service (TOS) bits and embedded into every packet. Follow the steps in Procedure 4.2, “Setting Network Priorities for File Sharing Services” to configure prioritization of two file sharing services (NFS and Samba).
Procedure 4.2. Setting Network Priorities for File Sharing Services
net_priosubsystem is not compiled in the kernel, it is a module that must be loaded manually. To do so, type:
- Attach the
net_priosubsystem to the
mount -t cgroup -o net_prio net_prio /cgroup/net_prio
- Create two cgroups, one for each service:
- To automatically move the
nfsservices to the
nfs_highcgroup, add the following line to the
CGROUP_DAEMON="net_prio:nfs_high"This configuration ensures that
nfsservice processes are moved to the
nfs_highcgroup when the
nfsservice is started or restarted. For more information about moving service processes to cgroups, refer to Section 2.9.1, “Starting a Service in a Control Group”.
smbddaemon does not have a configuration file in the
/etc/sysconfigdirectory. To automatically move the
smbddaemon to the
samba_lowcgroup, add the following line to the
*:smbd net_prio samba_lowNote that this rule moves every
smbddaemon, not only
/usr/sbin/smbd, into the
samba_lowcgroup.You can define rules for the
winbindddaemons to be moved to the
samba_lowcgroup in a similar way.
- Start the
cgredservice to load the configuration from the previous step:
service cgred startStarting CGroup Rules Engine Daemon: [ OK ]
- For the purposes of this example, let us assume both services use the
eth1network interface. Define network priorities for each cgroup, where
1denotes low priority and
10denotes high priority:
echo "eth1 1" > /cgroup/net_prio/samba_low~]#
echo "eth1 10" > /cgroup/net_prio/nfs_high
- Start the
smbservices and check whether their processes have been moved into the correct cgroups:
service smb startStarting SMB services: [ OK ] ~]#
cat /cgroup/net_prio/samba_low16122 16124 ~]#
service nfs startStarting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS mountd: [ OK ] Stopping RPC idmapd: [ OK ] Starting RPC idmapd: [ OK ] Starting NFS daemon: [ OK ] ~]#
cat /cgroup/net_prio/nfs_high16321 16325 16376Network traffic originating from NFS now has higher priority than traffic originating from Samba.
net_priosubsystem can be used to set network priorities for client applications, for example, Firefox.