Monday, June 18, 2012

Throttle The Disk I/O Rate: Limit disk I/O for rsync Tool

Q. I run a backup script called /root/backup.sh which runs rsync command. However, rsync makes a lots of disk I/O and network I/O. I'd like to reduce both disk I/O and network I/O. I've 10Mbps server connection and 160GiB SATA hard disk. How do reduce disk I/O so that the entire system doesn't die or become unresponsive?

A. This is well known issue. There are two methods to control or throttle the disk and network I/O rate under UNIX / Linux.

Method # 1: Limit I/O bandwidth

The --bwlimit option limit I/O bandwidth. You need to set bandwidth using KBytes per second. For example, limit I/O banwidth to 10000KB/s (9.7MB/s), enter:
# rsync --delete --numeric-ids --relative --delete-excluded --bwlimit=10000 /path/to/source /path/to/dest/

Method # 2: Take control of I/O bandwidth using ionice utility

ionice command provide more control as compare to nice command. This program sets the io scheduling class and priority for a program or script. You can totally control disk i/o.

No comments:

Post a Comment