I'm looking for a way to limit a processes disk io to a set speed limit. Ideally the program would work similar to this:$ limitio --pid 32423 --write-limit 1MLimiting process 32423 to 1 megabyte per second hard drive writing speed.
How to Throttle per process I/O to a max limit?
hard disk;io;process management;limit;ulimit
That is certainly not trivial task that can't be done in userspace. Fortunately, it is possible to do on Linux, using cgroup mechanizm and its blkio controller. Setting up cgroup is somehow distribution specific as it may already be mounted or even used somewhere. Here's general idea, however (assuming you have proper kernel configuration):mount -t tmpfs cgroup_root /sys/fs/cgroupmkdir -p /sys/fs/cgroup/blkiomount -t cgroup -o blkio none /sys/fs/cgroup/blkioNow that you have blkio controller set, you can use it:mkdir -p /sys/fs/cgroup/blkio/limit1M/echo X:Y  1048576 > /sys/fs/cgroup/blkio/limit1M/blkio.throttle.write_bps_device Now you have a cgroup limit1M that limits write speed on device with major/minor numbers X:Y to 1MB/s. As you can see, this limit is per device. All you have to do now is to put some process inside of that group and it should be limited:echo $PID > /sys/fs/cgroup/blkio/limit1M/tasksI don't know if/how this can be done on other operating systems.