copying a file slows down your linux system?

In my case, I was working on a very busy web server and when trying to copy a 500GB file, the sites were slowing down really bad.

There is a handy tool which you can use to lower the priority on disk usage for specified processes called 'ionice'.

There are 3 levels of priority:
1 - real time
2 - best effort
3 - idle

'Real time' means that the process is given disk access as soon as it needs it. You shouldn't be using this level unless you know what you're doing. the result may almost certainly be system lockup from your point of view and you're gonna need a hard reboot.

'Best effort' is how a default program is being run.

'Idle' means that the process will get disk access only when no other process needs it. by using this level you're theoretically sure that the process you're setting to 'idle' priority won't slow down any other programs running that need disk access. it will also make it really slow if the system is busy on io. so, arm yourself with a long patience, long as big a file you're trying to copy (in my case :( )

The command format is as follows:
ionice -c[priority] -n[data] -p[process_id] command

- priority can be 1,2 or 3 as explained above
- data can be set in the case of 'best effort' or 'real time' to specify the priority of the process compared to the ones in the same priority level. it can be in the range 0-7, the lower the number the highest the priority is. the processes with the same level are served sequentially.
- process_id - you can get the process id from top, ps or anything you can use to get process id info
- command - you can issue a command directly with ionice and set it's priority in this way.

Here are a few examples that should demonstrate the usage really well.
- change the priority to idle for a process id
ionice -c3 -p12734

- get the priority of a process
ionice -p12734

- run a command with idle priority
ionice -c3 command

A nice usage is to set an entire shell to an idle priority. for example you login through ssh and get the shell's process id with 'echo $$' and you change it's priority to idle. whatever you will do in that shell will be set to the idle priority level.
echo $$
ionice -c3 -p[shell_process_id]

Technology: 

Comments

Pages

Add new comment