Using ionice to adjust I/O priority on Linux
A busy Linux server can have plenty of spare CPU capacity while applications still feel slow because disks or solid-state storage are saturated. Backups, log compression, database maintenance and large file transfers compete with interactive services for the same I/O queue. The ionice command helps administrators control that competition by assigning an I/O scheduling class and priority to a process.
This is useful on Fedora, RHEL, CentOS Stream and related systems, particularly when a scheduled job affects an Nginx site or a database. It is different from nice: nice influences CPU scheduling, while ionice influences how the kernel treats block-device requests. The result depends on the active I/O scheduler and storage hardware, so changes should be measured rather than assumed.
Check the current I/O environment
Confirm that ionice is installed before changing a workload:
command -v ionice
ionice --version
To inspect the scheduler used by a block device, replace sda with the correct device:
cat /sys/block/sda/queue/scheduler
A result such as [mq-deadline] kyber bfq shows the active scheduler inside square brackets. Historically, ionice had its clearest effect with CFQ. Modern multi-queue schedulers and some NVMe devices may support I/O priority differently, so use iostat or pidstat to verify the outcome.
Find a process ID and inspect its current class:
pgrep -af rsync
ionice -p 2841
The command reports the class and priority for process 2841. CPU niceness appears separately in tools such as ps, and changing one does not automatically change the other.
Understand the scheduling classes
The best-effort class is the normal default. Its priority ranges from 0, the most favourable value, to 7, the least favourable:
ionice -c 2 -n 6 -p 2841
This lowers the disk preference of a running backup without stopping it. To start a new command with the same policy, place ionice before the command:
ionice -c 2 -n 7 tar -czf /srv/backup/site.tgz /var/www
The idle class lets a process perform I/O only when the system has no higher-priority disk work:
ionice -c 3 updatedb
It is often appropriate for indexing, checksum generation and archival jobs. Realtime class priority is reserved for urgent workloads and requires elevated privileges or suitable capabilities:
sudo ionice -c 1 -n 0 -p 2841
Use this sparingly. Giving one process realtime I/O access can make other services appear frozen, particularly on a heavily loaded virtual machine.
Apply it to scheduled maintenance
A common pattern is to reduce the impact of nightly backups, log rotation or database exports. Australian organisations often schedule these jobs after office hours in Sydney, Melbourne or Brisbane, but a fixed local time may still overlap with overnight reporting, cloud replication or customer traffic across time zones. Apply the policy directly in the script or systemd unit rather than relying on an administrator to remember it.
For a cron entry, use an absolute path and log the result:
30 1 * * * /usr/bin/ionice -c 3 /usr/local/sbin/nightly-backup >> /var/log/nightly-backup.log 2>&1
For a systemd service, add an override:
sudo systemctl edit report-export.service
[Service]
IOSchedulingClass=idle
Then reload and restart the unit:
sudo systemctl daemon-reload
sudo systemctl restart report-export.service
Systemd passes these settings to the service process and generally makes the configuration easier to audit than a long shell command.
Measure impact instead of guessing
Watch device utilisation and latency while the workload runs:
iostat -xz 1
pidstat -d -p 2841 1
High %util, rising await times or increasing queue depth indicate contention. Compare the same job with and without ionice, ideally on a staging host. An NVMe device can complete requests so quickly that changing the class makes little visible difference, while a busy SATA disk or network-backed virtual volume may respond noticeably.
Keep unrelated activity out of the test. A desktop browser loading advertisements, video or Megaways slot-machine content can create extra reads that distort a simple benchmark. On a small office server using an NBN connection, network transfer limits may be the real bottleneck rather than local disk priority.
Combine I/O priority with wider tuning
ionice controls process-level disk preference, but it does not fix insufficient memory, a slow filesystem, poor database indexes or an overloaded storage backend. Check memory pressure with free -h, examine kernel messages with dmesg, and review filesystem capacity using df -h and df -i.
For broader kernel and virtual-memory work, review sysctl kernel tuning separately from I/O policy. Raising dirty-page limits or altering writeback behaviour can affect every service, so record the original values and change one setting at a time.
Australian operators should also consider data-handling obligations when moving backups between local and overseas storage. The Privacy Act 1988 and sector-specific rules can influence retention, access and cross-border disclosure. Australian cloud and colocation providers in Sydney and Melbourne may offer suitable residency, but storage performance and I/O scheduling still need testing under the provider’s virtualisation layer.
Run ionice -c 3 on one non-critical maintenance job, monitor it with iostat -xz 1, and compare its completion time with the server’s application latency before extending the policy.