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

I've tried using 'rate' to limit the traffic speed of a VM inside the config file but that only limits the incoming traffic speed of traffic to the VM. I want to limit the speed traffic can flow both ways.


share|improve this question
how do you do limit it? – silviud Apr 18 '11 at 23:02
@silviud I use the 'limit' setting in the Xen VM config file. – Joel Kennedy Apr 18 '11 at 23:40
up vote 0 down vote accepted

I use XEN 4.2.2 at the time of this reply.

  • Remove rate=X from your guest config file and shut it down.
  • Make sure your kernel have at least the following enabled:
  • IP: advanced router
  • TCP: advanced congestion control (all options enabled)
  • QoS and/or fair queueing (all options enabled expect the debug ones)
  • Install 'tc' command
  • Verify it's working by running: tc -s qdisc ls dev eth0

If you get no errors, you're ready to modify /etc/xen/scripts/vif-bridge

Find this word 'online)'

Just add before ;;

tc qdisc add dev "$dev" root tbf rate 120mbit burst 20mbit latency 5ms peakrate 125mbit minburst 20mbit mpu 64

So the modified version of vif-bridge should look like this:

        setup_virtual_bridge_port "$dev"

        mtu="`ip link show $bridge | awk '/mtu/ { print $5 }'`"

        if [ -n "$mtu" ] && [ "$mtu" -gt 0 ]


                ip link set $dev mtu $mtu || :


        add_to_bridge "$bridge" "$dev"

        tc qdisc add dev "$dev" root tbf rate 120mbit burst 20mbit latency 5ms peakrate 125mbit minburst 20mbit mpu 64


Find this word 'offline)'

Append to first line: do_without_error tc qdisc del dev "$dev" root

        do_without_error tc qdisc del dev "$dev" root

        do_without_error brctl delif "$bridge" "$dev"

        do_without_error ifconfig "$dev" down


Using the above TBF rule your guest should have roughly 12.5MB/s upload and 14.0M/s download speed; a bit over 120Mbps

If you upload/download same time, both upload and download speed should be about 7.5MB/s ~ 150Mbps total bandwidth

This is what I got after an hour tweaking. If you find better values; please let us know

share|improve this answer

While I'm not sure of a way to limit the inbound traffic to a Xen DomU (which is actually what you claim to have already done), I have limited outbound traffic in the past by making a very simple change to the vif definition in my DomU's config file. For example, for one guest, I am using:

vif = [ 'rate=5Mb/s , bridge=xenbr0' ]

Like I said, though, this will only limit the rate of outbound traffic.

I've also read (but haven't tried) that you have the option of specifying a time window to tweak the latency/throughput, as well, with a syntax like the following:

vif = [ 'rate=5Mb/s@25ms , bridge=xenbr0' ]


share|improve this answer

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.