bashserverloadniceionice

Nice / IOnice which one first? Does it matter? Any other way to reduce server load on a script?


I've been trying the "nicer" way to run a gzip from a bash script on an active server, but it somehow manages to get the load average above what I would wish it would be.

Which of the following would be softer on the I/O and the CPU?

Is there another way I'm not aware of?

  1. /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 gzip -9 -q foo*

or

  1. /usr/bin/ionice -c2 -n7 /usr/bin/nice -n 19 gzip -9 -q foo*

Also, is there another commands such as ulimit that would help reducing the load on the server?


Solution

  • I'm not familiar with the ionice thing, but nice just means that if another process want's to use the CPU, then the nice process will be more willing to wait a bit.

    The CPU load is unaffected by this since it's just a measure of the length of the "run queue", which will be the same.

    I'm guessing it'll be the same with ionice, but affecting disk load.

    So, the "niceness" only affects how willing your process is to allow others to go before you in the queue, but in the end the load will be the same because the CPU/disk has to carry out the job.

    ANALOGY: Think of a person behind a checkout counter as an analogy. They still has to process the queue, but the people in the queue may be nice to each other and let others pass before them to the counter. The "load" is the length of that queue.