All Products
Search
Document Center

Query and Case Analysis Linux IO Load

Last Updated: Apr 27, 2022

Disclaimer: This topic may contain information about third-party products. The information is for reference only. Alibaba Cloud does not make a guarantee in any form of the performance and reliability of the third-party products, and potential impacts of operations on these products.

 

Overview

This article mainly explains the query and case analysis of Linux IO load.

 

Description

Take note of the following items:

  • Before you perform high-risk operations such as modifying the specifications or data of an Alibaba Cloud instance, we recommend that you check the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
  • Before you modify the specifications or data of an Alibaba Cloud instance, such as an Elastic Compute Service (ECS) instance or an ApsaraDB RDS instance, we recommend that you create snapshots or enable backups for the instance. For example, you can enable log backups for an ApsaraDB RDS instance.
  • If you have granted specific users the permissions on sensitive information, such as usernames and passwords, or submitted sensitive information in the Alibaba Cloud Management Console, we recommend that you modify the sensitive information at the earliest opportunity.

 

Query and Analysis of IO Load

Use iostat to view disk IO load from system latitude

iostat is not a built-in tool for common Linux distributions. It is included in the sysstat software package and can be used only after you install it through yum or apt-get. Specific installation methods are not detailed in this article.

 

Usage notes

Run the following command to view the disk I /O load:

iostat -d -k 2

Note:

  • -d: displays the usage status of the device (disk).
  • -k: indicates that some powers that use block as the unit use kB as the unit.
  • 2: The data display is refreshed every 2 seconds.

If an output similar to the following one is returned, one of the solutions is applicable to your system kernel version:

Linux 3.10.0-123.9.3.el7.x8664 (centos)     06/27/2016     _x86_64    (1 CPU)
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
xvda 0.58 0.12 3.75 278001 8820028
xvdb 0.00 0.00 0.00 740 0
xvdc 0.00 0.00 0.00 1388 0
xvde 0.00 0.00 0.00 2035 0
xvdf 0.00 0.00 0.00 740 0

Tips: For more information about the parameters and the response, see the man help of iostat.

 

Use iotop to view disk IO load from process latitude

iotop is not a common Linux distribution tool. You must install iotop through yum or apt-get before you can use it. Specific installation methods are not detailed in this article.

Tip: You can use iotop to sort the I /O usage of processes in the system from the process dimension.

 

Usage notes

If you run the iotop command, you can see an interface similar to the following.

 

System display description
  • By default, the sorted fields are sorted in reverse order of IO usage. You can use the left and right arrows to manipulate the sorted fields.
  • Press r to switch the sort mode.
  • Press o to display only processes with disk IO activity.
  • For more information about the parameters and the returned results, see the man help of iotop.

 

IO Load Related Operation Cases

The kjournald process occupies high IO resources.

Issue

Use iotop to troubleshoot and analyze, and find that the kjournald process occupies a large amount of I /O resources.

 

Cause

The kjournald process is the core process of the ext3 file system that performs I /O data operations. It consumes CPU and memory resources when writing and reading data to disk. This problem is usually caused by the cyclic write data of the ext3 file system, and the journal size is constantly increasing, and then it is full.

 

Solution

Run the following command and run the dumpe2fs command to check the Journal size configuration of the corresponding partition. Then, try to increase the value to check whether the problem is mitigated.

dumpe2fs /dev/xvda1  grep Journal

If an output similar to the following one is returned, one of the solutions is applicable to your system kernel version:

dumpe2fs 1.42.9 (28-Dec-2013)
Journal inode: 8
Journal backup: inode blocks
Journal features: journal_incompat_revoke
Journal size: 128M
Journal length: 32768
Journal sequence: 0x00010ffb
Journal start: 10953

 

Improve IO performance with 4K alignment

This section describes how to format a disk and automatically configure 4K alignment by using the following script.

Tip: Running this script automatically formats all data disks. If you do not purchase a new disk, make sure that the data on the disk has been backed up. You can use snapshots to back up disks. For more information, see Create a snapshot.

  1. Decompress the following package, and upload the decompressed script to the target server.
    auto_fdisk.zip
  2. Go to the directory where the script is located, use the root user, run the following commands in sequence, add execution permissions to the script, and then run the script.
    chmod +x ./auto_fdisk.sh
    ./auto_fdisk.sh

 

Applicable scope

  • Elastic Compute Service (ECS)