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 1M
Limiting process 32423 to 1 megabyte per second hard drive writing speed.
That is certainly not trivial task that can't be done in userspace. Fortunately, it is possible to do on Linux, using
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):
Now that you have
Now you have a cgroup
I don't know if/how this can be done on other operating systems.
It doesn't set absolute IO limits, it sets IO priority and 'niceness' - similar to what
From the man page:
ionice - set or get process I/O scheduling class and priority DESCRIPTION This program sets or gets the I/O scheduling class and priority for a program. If no arguments or just -p is given, ionice will query the current I/O scheduling class and priority for that process. When command is given, ionice will run this command with the given arguments. If no class is specified, then command will be executed with the "best-effort" scheduling class. The default priority level is 4.
systemd provides a wrapper for cgroup-manipulated invocations of processes. From the systemd-run(1) man page:
The following command invokes the updatedb(8) tool, but lowers the block IO weight for it to 10. See systemd.resource-control(5) for more information on the BlockIOWeight= property.
Consider using the