LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can I limit a process' disk io bandwith (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-limit-a-process-disk-io-bandwith-705944/)

wastingtime 02-19-2009 11:31 AM

How can I limit a process' disk io bandwith
 
I need to run an archiving process that is cpu and disk io intensive.

It is easy to make sure it does not steal the cpu from more important processes: nice myprocess

However, even when running at a lower priority (thanks to nice) it manages to generate enough disk io to impact the performance of more important processes.

I would like to be able to limit the process disk io to e.g. 10Mbyte/sec; alternatively, to 10% of the available bandwidth.

ulimit does not seem to have such option.

Is there another command ?

Can I do that programmatically (i.e. write my own command ... but then someone must have wrote one already)?

lazlow 02-19-2009 12:47 PM

The usual answer here is to run the archive as a cron job. Set it to run at 2am (or whenever the machine has little use) and that way you can give it all the resources it wants without interfering with your daily tasks.

wastingtime 02-19-2009 01:04 PM

This machine runs 24X7

Valery Reznic 02-20-2009 12:22 AM

Quote:

Originally Posted by wastingtime (Post 3449869)
I need to run an archiving process that is cpu and disk io intensive.

It is easy to make sure it does not steal the cpu from more important processes: nice myprocess

However, even when running at a lower priority (thanks to nice) it manages to generate enough disk io to impact the performance of more important processes.

I would like to be able to limit the process disk io to e.g. 10Mbyte/sec; alternatively, to 10% of the available bandwidth.

ulimit does not seem to have such option.

Is there another command ?

Can I do that programmatically (i.e. write my own command ... but then someone must have wrote one already)?

What about following:

Create shared library slow_io.so with functions read and write.
Those funcion should usleep(your_timeout) and then call, original one

Run your application as
Code:

LD_PRELOAD=slow_io.so YourApplication
You may also need to intercept other io syscalls, such as pread/pwrite

syg00 02-20-2009 01:18 AM

"man ionice"

Valery Reznic 02-20-2009 01:21 AM

Quote:

Originally Posted by syg00 (Post 3450651)
"man ionice"

Cool. Never hear about it before

wastingtime 02-21-2009 12:31 PM

just what i need, only available from 2.6.13 and up though.


All times are GMT -5. The time now is 09:15 PM.