How to limit network usage for concrete application in linux that is running in it?

listed in answer

How to limit network usage for concrete application in linux that is running in it?
0 votes, 0.00 avg. rating (0% score)

ANSWER:

tc, iptables etc can all do this, but just to be different:

You can use Linux kernel feature cgroups and its net_cls module for limiting xapian-replicate-server. Something like this should do:

mount -t cgroup -onet net /sys/fs/cgroup
cd /sys/fs/cgroup
mkdir xapian-replicate-server
/bin/echo $$ > xapian-replicate-server/tasks
/bin/echo 2048 > xapian-replicate-server/net.tcp
/bin/echo 4096 > xapian-replicate-server/net.tot
however_you_launch_xapian-replicate-server

This would create a new cgroup for Xapian and give it total of 2048 kilobytes/s TCP traffic bandwidth and 4096 kilobytes/s of total whatever network traffic bandwidth.

by Janne Pikkarainen from http://serverfault.com/questions/382551