Limit disk I/O one program creates?

Hardware: one virtualization server. Dual Nehalem, 24GB RAM, 2 TB mirrored HD.

Software: Debian, KVM, virt-manager on the server with several virtual machines that use Linux too. 2 TB Disk is a big LVM, each VM gets a logical volume and makes its own partitions in that.

Problem: One of the programs that runs on one of the VMs creates huge disk load. This never was an issue, because the program never ran on such a powerful hardware. Now the CPUs are fast, and lots of I/O is the result. We cant do much against that at the moment, because the tool is a black box. On the other hand, the speedy computation is welcome. The program creates about 5 GB of temp files which get overwritten during the next iteration.

Question: How can we limit the disk I/O for the process?


Solution 1:

You want the ionice command. For idle priority (lowest priority):

ionice -c3 bash

You can use the regular nice command to slow down the CPU priority as well which maybe would limit IO as a side effect too.

You might be able to also limit the amount of FDs on the program with ulimit. This might limit the max open files the application is capable of, but it also might just break it.

Yet another option might be to go buy a bunch more memory and map those temp files to a ram disk with mount, taking the load off of the disk entirely. You could of course do the same by adding another disk for the temp files as well.

Solution 2:

RHEL6 will also support cgroups, which lets you do a finer grained tuning. You could try to look that up in Debian as well