Recently, in my research, I want to throttle the I/O and network bandwidth of my program so as to show my program is robust in different senarios. In practice, we may also want to limit the resources used by certain programs (rsync, wget, …). Fortunately, this is possible in Linux. Next, I will show how to do it on Ubuntu 14.04. I believe it’s doable on any Linux distributions. For network bandwidth limiting, we will use a program called trickle. Install trickle:
1 |
sudo apt-get install trickle |
Usage of trickle:
1 |
trickle -s -u <up link limit in KB/s> -d <down link limit in KB/s> <path-to-your-program> [args...] |
Example: limit the bandwidth for scp under 10MB/s
1 |
trickle -s -u 10240 -d 10240 scp ~/graph-data-origin/twitter_rv.net linux15:~/ |
An alternative for network bandwidth limiting is wondershaper. But I found that tirckle works better. For disk bandwidth limiting, you can use the cgroup[…]