Docker Community Forums

Share and learn in the Docker community.

Traffic shaping on docker containers

docker

(Shrey67) #1

Unable to accurately throttle the bandwidth using TC rules on docker containers

Expected behavior

On setting following TC rules, the expected bandwidth must be 150 Mbps

tc qdisc add dev eth0 handle 1: root htb default 11
tc class add dev eth0 parent 1: classid 1:1 htb rate 150Mbps
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 150Mbit
tc qdisc add dev eth0 parent 1:11 handle 10: netem delay 50ms

Actual behavior

I am setting the BW to be around 150 Mbps, but I am observing it to be around 130 Mbps

I am using amazon ec2 instances as the host machine. The deviation from the expected to observed is around 10% to 20% (It varies from one instance to the other). Whereas the latency is shaped with more accuracy (less than 2%).

Additional Information

Steps to reproduce the behavior

  1. Create two docker containers

  2. Apply the TC rules on both containers (over here, network interface=eth0, BW = 150Mbps, Latency = 50ms. This can vary from system to system)
    tc qdisc add dev eth0 handle 1: root htb default 11
    tc class add dev eth0 parent 1: classid 1:1 htb rate 150Mbps
    tc class add dev eth0 parent 1:1 classid 1:11 htb rate 150Mbit
    tc qdisc add dev eth0 parent 1:11 handle 10: netem delay 50ms

  3. do an iperf between these two containers.