Rate-limit userspace processes and virtual machines
In a previous post,
I mentioned how to rate-limit Unix pipes.
But what can we do about other processes?
Trickle
Trickle is a userland bandwith shaper that can be used to manage the bandwith usage of any userspace process (unless it is statically linked or setuid):
trickle -d 300 -u 300 firefox
starts firefox and limits it to 300 KB/s downstream and upstream.
Libvirt Virtual Machines
To limit the bandwidth usage of a whole virtual machine, we can use Libvirt’s QoS capabilities:
<bandwidth>
<inbound average="300" peak="800"/>
<outbound average="300" peak="800"/>
</bandwidth>
inside of the <interface>
block of a virtual machine aims for an
average bandwith usage of 300 KB/s with a maximum peak of 800 KB/s,
each up- and downstream.
I mostly use this to upgrade one or more virtual machines in the background without disturbing other applications or video calls too much.