Experiencing Disk I/O Lag on Linux? Step-by-Step Guide to Identify the Culprit Process!

Experiencing Disk I/O Lag on Linux? Step-by-Step Guide to Identify the Culprit Process!

Have you ever encountered a situation while using Linux where the disk suddenly becomes sluggish, the system response is delayed, and even entering commands takes forever? It is very likely that a certain process is excessively reading and writing to the disk, causing I/O congestion!

Soโ€”๐Ÿ‘‰ How can you quickly identify which process is causing high disk I/O?๐Ÿ‘‰ How can you monitor disk read/write activity in real-time? This article will guide you through a few commands to quickly find the “hidden culprit”!

1. Use iotop to Quickly Identify “High I/O Processes”

If you want to view in real-time which processes are excessively reading and writing to the disk, <span>iotop</span> is your best choice!

sudo iotop -ao

Parameter explanation:

  • โ€ข <span>-a</span>: Displays accumulated I/O total
  • โ€ข <span>-o</span>: Only shows processes that are currently performing I/O

Effect screenshot๐Ÿ‘‡ You can clearly see which process has read and written how much data, making it obvious who the “disk killer” is.

Experiencing Disk I/O Lag on Linux? Step-by-Step Guide to Identify the Culprit Process!

2. Use pidstat to Monitor I/O Activity of Each Process

In addition to real-time monitoring, you can also use <span>pidstat</span> to observe I/O usage over a period of time:

pidstat -d 1

It refreshes every second, displaying the read and write speed of each process:

Time       UID       PID    kB_rd/s   kB_wr/s  Command
14:20:01     0      1234     105.00      0.00   mysqld
14:20:01     0      2345       0.00     32.00   rsyslogd

๐Ÿ” Which process reads the most and writes the most is clear at a glance.

3. dstat: Comprehensive View of Disk and Process

If you prefer a tool that provides multiple views at once, <span>dstat</span> can display:

  • โ€ข CPU usage
  • โ€ข Disk read/write speed
  • โ€ข The current process that is most “disk-intensive”

The command is as follows:

dstat -cdlmn --top-io

Real-time, comprehensive, and intuitive, it is very suitable for system administrators or developers for daily troubleshooting.

Experiencing Disk I/O Lag on Linux? Step-by-Step Guide to Identify the Culprit Process!

4. Want to Dive Deeper? Check <span>/proc/[pid]/io</span>

If you have already identified a certain process and want to know how much it has read and written to the disk, you can check its <span>/proc</span> directory:

cat /proc/1234/io

You will see content like this:

read_bytes: 50000
write_bytes: 100000

๐Ÿ” Pay special attention to <span>read_bytes</span> and <span>write_bytes</span>, which will help you assess its actual disk pressure.

5. No Tools? Quick Installation!

If you find that the command prompts “not found”, you can install it directly:

# Ubuntu / Debian
sudo apt install iotop sysstat dstat

# CentOS / RHEL
sudo yum install iotop sysstat dstat

(It is recommended to also install <span>htop</span> and <span>btop</span> for a more visually appealing effect)

Conclusion

Once disk I/O issues arise, they not only affect current business performance but can even cripple the entire system. Mastering these commands is like having a “system magnifying glass” in your hand, allowing you to quickly pinpoint the source of the problem and mitigate losses in a timely manner!

๐Ÿ“Œ Save + Share, it can be a lifesaver in critical moments! ๐Ÿ“ฎ If you have more topics on Linux operations and performance tuning, feel free to leave a message for discussion~

Previous Reviews

  • 100 High-Frequency Linux Operation Commands, Recommended to Save!

  • Differences Between GPU and CPU

  • Comprehensive Guide to Firewalld: Principles + Practice, Easily Manage Linux Firewall!

  • Common Network Commands for Linux Operations

  • Differences Between TLS and SSL

  • Common Commands for Kirin System V10

  • Docker Cleanup of Unused Images or Images Tagged as None

  • Is the Service Problematic When Tomcat Thread Count Exceeds 350?

  • Percona Toolkit to Solve MySQL Master-Slave Synchronization Issues

  • Differences Between Chip Architectures: X86, ARM, RISC-V, MIPS, POWERPC, SPARC

  • What Are the Master Components of K8S? What Is the Role of Each Component?

Leave a Comment