Currently nginx uses all my bandwidth. How do I leave some for rsync?
This is a sketch and you need to figure out all the details yourself, but this is how it should be possible:
What you want can be accomplished by using two Linux specific kernel facilities, namely
What you basically need to is to put nginx and it's children into an own cgroup, use the
You of course need to create the same cgroup setup for rsync. Take care that you can do all the cgroups machinery before you call rsync or setup rsyncd accordingly.
This 'tag' that is being attached from net_cls then can be used as classid in the filter attached to qdisc to pass the traffic to different classes. You also need to define bandwidth classes that contain the bandwith limits you want to assign to your two cgroups say 500Mbit/s ceiling for nginx and 500Mbit/s for rsync. Please note that the usual caveats about QoS and rate limiting or queuing TCP apply.
This code would rate limit port 80,443 (HTTP,HTTPS) to a maximum of 0.5Mb and burst to 0.6Mb. Tweak/adjust to suit your requirements.