We know that the Linux storage system I/O stack consists of a file system layer, a general block layer, and a device layer.
In this article, let’s take a look at the performance metrics of the disk and how to view them.
When measuring disk performance, we often mention five common metrics: utilization, saturation, IOPS, throughput, and response time. These five metrics are the basic metrics for measuring disk performance.
Utilization: The percentage of time the disk takes to process I/O. Overuse, such as more than 80 percent, often means a performance bottleneck in disk I/O.
Saturation: Refers to how busy the disk handles I/O. Oversaturation means that the disk has a serious performance bottleneck. When the saturation is 100%, the disk cannot accept new I/O requests.
IOPS(Input/Output Per Second): Refers to the number of I/O requests per second.
Throughput: The size of I/O requests per second.
Response time: Refers to the time between sending an I/O request and receiving a response.
It should be noted here that with regard to utilization, we only consider the presence or absence of I/O, not the size of the I/O. That is, when the utilization is 100%, the disk is still likely to accept new I/O requests.
In general, when selecting a server for an application, you first benchmark the I/O performance of the disk so that you can accurately evaluate the disk performance to determine whether it meets the needs of the application.
Of course, this requires you to test the performance of different I/O sizes (usually between 512B and 1MB) in various application scenarios such as random read, sequential read, random write, and sequential write.
The first thing to observe is the usage of each disk. iostat is the most commonly used disk I/O performance observation tool. It provides a variety of common performance metrics, such as per-disk utilization, IOPS, and throughput. Of course, these indicators actually come from /proc/diskstats.
The following is an example of the output of iostat:
Among the above indicators, you need to note that:
%util is the disk I/O usage we mentioned earlier
r/s and w/s are IOPS
rkB/s and wkB/s are throughput
r_await and w_await are response times
You may have noticed that iostat does not directly obtain the saturation of the disk. In fact, there is usually no easy way to measure saturation. However, you can compare the observed average request queue length or the wait time to complete a read or write request with the results of a benchmark, such as through fio, to comprehensively assess disk saturation.
In addition to the I/O situation per disk, the I/O situation of each process is also the focus of attention.
The iostat mentioned above only provides data to observe the overall I/O performance of the disk. The disadvantage is that there is no way to know which processes are reading and writing to the disk. To observe the I/O of a process, you can also use pidstat and iotop tools.
For example, to use pidstat
As you can see from the output of pidstat, it can see the I/O of each process in real time, including the following:
User ID (UID) and process ID (PID).
The size of the data read per second (kB_rd/s), in KB.
The size of the write request data issued per second (kB_wr/s), in KB.
The data size (kB_ccwr/s) of canceled write requests per second, in kilobytes.
Block I/O delay (iodelay), which includes the amount of time to wait for synchronized block I/O and swap-in block I/O to complete, in clock cycles.
In addition to using pidstat to view process disk I/O in real time, a common method for disk profiling is to sort processes based on I/O size. For this, I recommend the iotop tool. It is a top-like tool that allows you to sort processes by I/O size and find processes with larger I/O.
As you can see from this output, the first two lines represent the total disk read and write size of the process and the total actual read and write size of the disk. They may not be equal due to factors such as caches, buffers, I/O merges, and so on.
The rest represents the I/O situation of the process from various angles, including thread ID, I/O priority, disk read size per second, disk write size per second, swap percentage, and wait for I/O clock percentage.
In this article, I described performance metrics for Linux disk I/O and the View Performance Tools. We typically use several metrics, such as IOPS, throughput, utilization, saturation, and response time, to evaluate the I/O performance of a disk.
You can use iostat to get the I/O situation of the disk, or you can use pidstat, iotop, etc. to observe the I/O situation of the process. However, when analyzing these performance indicators, it is necessary to pay attention to the comprehensive analysis of the read/write ratio, I/O type, and I/O size.
Link: https://blog.devgenius.io/linux-disk-i-o-performance-1e920faba23
Source: Network (Copyright belongs to the original author, infringing and deleting)
– EOF –
Add the homepage Jun WeChat, not only Linux skills +1
Homepage Jun will also share Linux-related tools, resources and selected technical articles on personal WeChat, and share some interesting activities, job promotion and how to use technology to do amateur projects from time to time
Add a WeChat and open a window
1. Linux kernel debugging methods
2. Again: Unix is not Linux!
3. Explain Linux multi-threading in detail – mutexes, conditional variables, read-write locks, spin locks, semaphores
Got a harvest after reading this article? Please share it with more people
It is recommended to pay attention to “Linux enthusiasts” to improve their Linux skills
Likes and looks are the biggest support ❤️