DEV Community

loading...

Linux Capacity Planning Part -2

Ajay Singh
・6 min read

In the last post Linux Capacity Planning-1, we discussed about -

  • The linkage between capacity planning and performance
  • Package sysstats - its installation on various Linux flavours.

In this post, we will do a deep dive in iostat utility present in the sysstats package.

Iostat command is a command used to monitor the system's input/output (I/O) device load by observing the time the devices are active in relation to their average transfer rates. The iostat create reports that can be used to change system configuration to better balance the input/output between physical disks.

sample of Iostat command run without passing any argument will look as below

[root@ip-10-25-57-107 ec2-user]# iostat
Linux 4.14.173-137.229.amzn2.x86_64 (ip-10-25-57-107.ap-south-1.compute.internal)       05/24/2020      _x86_64_        (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.02    0.00    0.01    0.01    0.00   99.96

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              0.59         1.32         4.20     206156     654551

When the command is run without arguments, it generates a detailed report containing information since the system was booted. You can provide two optional parameters to change this:

iostat [option] [interval] [count]

  • interval parameter specifies the duration of time in seconds between each report
  • Count parameter allows you to specify the number of reports that are generated before iostat exits.

The first report generated by the iostat command provides statistics concerning the time since the system was booted unless the -y option is used (in this case, this first report is omitted). Each subsequent report covers the time since the previous report. All statistics are reported each time the iostat command is run. The report consists of a CPU header row followed by a row of CPU statistics. On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors. A device header row is displayed followed by a line of statistics for each device that is configured.

The interval parameter specifies the amount of time in seconds between each report. The first report contains statistics for the time since system startup(boot) unless the -y option is used (in this case, this report is omitted). Each subsequent report contains statistics collected during the interval since the previous report. The count parameter can be specified in conjunction with the interval parameter. If the count parameter is specified, the value of count determines the number of reports generated at interval seconds apart. If the interval parameter is specified without the count parameter, the iostat command generates reports continuously.

[root@ip-10-25-57-107 ec2-user]# iostat 1 5
Linux 4.14.173-137.229.amzn2.x86_64 (ip-10-25-57-107.ap-south-1.compute.internal)       05/24/2020      _x86_64_        (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.02    0.00    0.01    0.01    0.00   99.96

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              0.59         1.32         4.19     206164     655868

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              0.00         0.00         0.00          0          0

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              0.00         0.00         0.00          0          0

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              0.00         0.00         0.00          0          0

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              0.00         0.00         0.00          0          0

[root@ip-10-25-57-107 ec2-user]#

The iostat command generates two types of reports, the CPU Utilization and Device Utilization report.
The first section of the report is related to

  1. CPU Utilization Report
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

For multiprocessor systems, the CPU values are global averages among all processors.

The report has the following format:

%user - Show the percentage of CPU utilization that occurred while executing at the user level (application).

%nice- Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.

%system- Show the percentage of CPU utilization that occurred while executing at the system level (kernel).

%iowait- show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.

%steal- Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.

%idle- Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

2.The Device Utilization Report
The device report provides statistics on a per physical device or partition basis. Block devices and partitions for which statistics are to be displayed may be entered on the command line. If no device nor partition is entered, then statistics are displayed for every device used by the system, and providing that the kernel maintains statistics for it. If the ALL
keyword is given on the command line, then statistics are displayed for every device defined by the system, including those that have never been used.
Transfer rates are shown in 1K blocks by default unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. The
report may show the following fields, depending on the flags used:

Device- device/partition name as listed in /dev directory

tps- number of transfers per second that were issued to the device. Higher tps means the processor is busier

Blk_read/s- show the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second

Blk_wrtn/s- amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second

Blk_read- show the total number of blocks read

Blk_wrtn- show the total number of blocks written

You get more detailed information by extending - using -x option with iostat.

iostat -x

[root@ip-10-25-57-107 ec2-user]# iostat -x
Linux 4.14.173-137.229.amzn2.x86_64 (ip-10-25-57-107.ap-south-1.compute.internal)       05/24/2020      _x86_64_        (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.02    0.00    0.01    0.01    0.00   99.96

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.02    0.08    0.51     1.30     4.16    18.62     0.00    3.06    1.19    3.35   0.17   0.01

[root@ip-10-25-57-107 ec2-user]#

Below are the details of the fields

%util: how much time did the storage device have outstanding work (was busy).
svctm: indicate how fast does your I/O subsystem respond requests overall when busy. Actually, less you load your system, higher svctm is.

await: indicates how fast do requests go through. It is just an average.

avgqu-sz: how many requests are there in a request queue. Low = either your system is not loaded, or has serialized I/O and cannot utilize underlying storage properly. High = your software stack is scalable enough to load properly underlying I/O.

avgrq-sz: Just an average request size. can indicate what kind of workload happens.

wsec/s & rsec/s: Sectors read and written per second. Divide by 2048, and you’ll get megabytes per second.

r/s & w/s: Read and write requests per second. These numbers are the ones that are the I/O capacity figures, though of course, depending on how much pressure underlying I/O subsystem gets (queue size!), they can vary.

rrqm/s & wrqm/s: How many requests were merged by block layer.

We will continue with iostat in the next post.

Discussion (0)