Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any utility to limit the network throughput of a process after it has been launched? Simple example: you note that a user takes all your upload bandwidth using scp and you'd like to limit the rate or decrease the priority of the transfer.

I guess i could use a combination of iptables/tc or pf to achieve that, but i was wondering if there is a "one-shot" tool available (like trickle with a --pid option ^^) ?

share|improve this question
Did you mean "trickle"? – halp Dec 29 '10 at 17:08
Edit: I assumed "trickle" was intended. – Steven Monday Dec 29 '10 at 22:04

Unfortunately there is no such a solution for FreeBSD. There are many solutions like dummynet/ipfw or altq/pf which are used to limit network usage based on different patterns but not on pids.

On linux there is a way to limit network usage on a user basis:

iptables -t mangle -A OUTPUT -p tcp -m owner --uid-owner test -j MARK --set-mark 1

I think there is no solution to limit the network utilization based on pid.

share|improve this answer
FreeBSD's ipfw also can match traffic by uid – gelraen Jan 18 '11 at 10:47

lsof the process to get the network ports that the proc is using. Once you know which ports are being used you can use IPTABLES rules to rate limit these ports. These articles should give you a better idea:

share|improve this answer

In Linux, even combination of iptables and tc could be a hard problem, since the "--pid-owner" option was abandoned from "owner" iptables module (see note below the table here). In fact, only this association (packet--process) seems to be complicated, while we can easily do the rest, i.e. filter and limit packets quite efficiently.

share|improve this answer

I don't think there is a ready made solution for this. But, using standard Linux tools you can hack a script that will do the thing.

First, you can get a list of all connections of specific process with lsof. Then, you can create ingress policies with tc for those connections.

share|improve this answer

Crudely, if you nice the process down to +20, then anything else running on the system will get priority and the job will be scheduled less often, so will find it harder to fill the buffers or process packets, which should lead to some TCP throttling. It will be sporadic, but might help enough.

# renice 20 -p $pid
share|improve this answer
This is a very roundabout way of trying to control bandwidth and will really only work if the system is very heavily loaded -- On an idle system evan a process reniced to -20 will still get on the CPU as often as it wants. – voretaq7 Jan 24 '11 at 17:39
Right, but if this isn't bandwidth shared with other local computers, then if the machine is idle you mostly don't care if this process gets all the bandwidth. It's only when there's another process which tries to use bandwidth that it matters. We may haver different definitions of "very heavily loaded" -- if there's another process trying to run, it gets priority and so if the load average is >= 1 per core, this may help. I did note that it's crude but if it's the only available tool (FreeBSD) then it's at least worth a shot. – Phil P Jan 24 '11 at 22:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.