Icon Rufen Sie uns an
+49 441.309197-69 +49 441.309197-69
 
EN

Bandwidth limitation with Trickle

Posted by Daniel Rauer on Monday, June 16, 2014

Introduction

Limiting your bandwidth may seem to be illogical in times where people yearn for faster connectivity. We also do, and that is why this post is not about reducing your connection to the outside in general, but to shape your traffic where useful so other services can benefit from a higher bandwidth.

Our scenario

At our current office we cannot get rid of some network bottlenecks that every traffic has to pass: e-mail, browser traffic, scp data, VoIP calls and backups of our internal machines. The latter is what caused some trouble in the past: Most of our workstations are laptops - and only during office hours inside our headquarter - so backups of these machines have to be made during the day. As these machines are equipped with SSDs a backup (even worse: multiple at a time) could tie our network up in a way that it heavily affects other services like telephone calls.

Using individual backup times would improve the situation, but still not to a level we would have been satisfied with. So we came up with the idea to limit the bandwidth our backup jobs could use, as it is not important how long it takes to create a backup (as long as it stays within lets say 1-2 hours).

The first thing you find on the internet when looking for a multi-purpose, well- documented tool to limit the bandwidth of a certain process is trickle. When reading further you will discover that also on second and third glance trickle is the tool of your choice because of its versatile use cases. So we gave it a try and found it very useful for our situation.

Short introduction to trickle:

trickle is available on various linux distributions, available in official repositiories and licenced under BSD licence. It can be run in daemon mode, reducing the bandwidth system wide, or be used for each application or process individually, each with its own options.

Limiting transfer speed of bacula

There are several sources on the usage of trickle, so we will only describe here how the bacula-fd (bacula file daemon, the backup client) can be limited on Ubuntu machines:

# apt-get install trickle
# touch /usr/sbin/trickle_bacula-fd
# chmod a+x /usr/sbin/trickle_bacula-fd

Insert the following lines into trickle_bacula-fd:

#!/bin/bash

trickle -s -d 3000 -u 3000 /usr/sbin/bacula-fd $@

This will limit the up- and download speed of bacula to 3 MB/s.

After this you have to adapt the file /etc/init.d/bacula-fd. Replace the line

DAEMON=/usr/sbin/bacula-fd

with

DAEMON=/usr/sbin/trickle_bacula-fd

and restart the bacula-fd with:

# /etc/init.d/bacula-fd restart