Linux – Limit Hard Drive Write Speed by User in Linux

drivelinuxperformancewrite

Background:

I use a cluster with my coworkers and if anyone writes too many big files at the same time I can't even move the cursor in vim (the horror!). I'm not sure if it is more related to the number of files open or the "bandwith" of hard drive being used but it definitely only happens when a big write operation is taking place (including downloading big files). I know you can limit hard drive space by quotas per user, but I've never heard of being able to limit data transfer speeds.

Question

Is it possible to limit the amount of data written per second by a user in linux?

Best Answer

Use cgroups together with CFQ I/O scheduler (the default for many distributions). CFQ is aware of cgroups and can give any user, group or process only x% of disk I/O time.

So, if you have one cgroup called sequenceGeek, having 90% of maximum resources, you can then have another cgroup called coworkers, having 10% of resources. Or something similarly fair.

man cgrules.conf, man cgset and man cgconfig.conf should get you started. This at least in Fedora 16, did not have time to check other distributions right now if they have similar config file names. Probably they do.

EDIT: Oh, just noticed from your comments you are using NFS. Then your network might be saturated and you need to use QoS with tc and iptables. Google for Advances Linux Routing How-To, it has ready-made examples of throttling the traffic and creating priority classes. Or if possible, do the throttling at your firewall/router/load balancer.

Could also be an old kernel version having issues with NFS or bad NFS mount options.