Pages

Search This Blog

Showing posts with label Throughput. Show all posts
Showing posts with label Throughput. Show all posts

Sunday, December 6, 2020

Disk IOPS - Throughput, Block size...,

We all might have heard these terms IOPS/Throughput, Disk blocks, Latency etc., let's look into these details.

What is IOPS? 

Input/output operations per second (IOPS, pronounced eye-ops) is an input/output performance measurement used to characterize computer storage devices like hard disk drives (HDD), solid state drives (SSD), and storage area networks (SAN).
To meaningfully describe the performance characteristics of any storage device, it is necessary to specify a minimum of three metrics simultaneously: IOPS, response time, and (application) workload. Absent simultaneous specifications of response-time and workload, IOPS are essentially meaningless.
IOPS number vary greatly with the input parameters that testers use, including the balance of read and write operations, the mix of sequential and random access patterns, the number of worker threads and queue depth, as well as the data block sizes. 
 

Sequential and Random access on IOPS performance: 

Sequential operations access locations on the storage device in a contiguous manner and are generally associated with large data transfer sizes, e.g. 128 kB. 
Random operations access locations on the storage device in a non-contiguous manner and are generally associated with small data transfer sizes, e.g. 4kB. 

For HDDs and similar electromechanical storage devices, the random IOPS numbers are primarily dependent upon the storage device's random seek time, whereas, for SSDs and similar solid state storage devices, the random IOPS numbers are primarily dependent upon the storage device's internal controller and memory interface speeds. 

IOPS = 1000 milliseconds / (Average Seek Time + Average Latency), with the latter two also measured in milliseconds.

What is Average Latency and Average Seek Time: 

Average Latency is the time it takes the disk platter to spin halfway around. It is calculated by dividing 60 seconds by the Rotational Speed of the disk, then dividing that result by 2 and multiplying everything by 1,000 milliseconds. ((60 / RPM)/2)*1,000. 

Average Seek Time is the time it takes for the head (the piece that reads data) to reach the area on the disk upon which that data is stored. The head needs to move around the storage area in order to locate the targeted data. You must average both read and write seek times in order to find the average seek time. 

The reason for SSD's having higher IOPS is because that for solid state drives, the average latency drops significantly, as there is no rotating disk inside. The seek time is also nil/null/N/A. 

While traditional HDDs have about the same IOPS for read and write operations, most NAND flash-based SSDs are much slower writing than reading due to the inability to rewrite directly into a previously written location forcing a procedure called garbage collection. 

 

What is Throughput? 

Throughput measures the data transfer rate to and from the storage media in megabytes per second.The disk throughput describes how many data may be transferred per second,hence disk block size play an important role: 

throughput = [IOPS] * [block size] 

Let's consider as the sample the 3000 IOPS and SQL database engine, the block size in terms of db engine is called the page size and for SQL Server it's equal to 8 KB. If you wish to calculate the actual throughput, if the IOPS defined, you will end up with the formula below:

 throughput = [IOPS] * [block size] = 3000 * 8 = 24 000 KB/s = 24 MB/s 

IOPS can therefore become a bottleneck for throughput. It is likely that your CPU and memory will not be a limiting factor, as they can handle more information per second than most storage devices and networks. A serially-attached storage device might only have a maximum throughput of up to 2,812 MBps, while Ethernet reaches up to 12,500 MBps and fiber channel networks reach 4,000 MBps. The size and number of blocks traversing the network can make a big difference in throughput. A 1 MB block will take longer to pass through the network but you may not move as many of them. A 4 KB block will move very quickly, but you’ll likely face a high volume. 

 

So what is a Block size/blocks? 

A sector is a physical spot on a formatted disk that holds information (please see the above disk diagram). When a disk is formatted, tracks are defined (concentric rings from inside to the outside of the disk platter. Each track is divided into a slice, which is a sector. On hard drives and floppies, each sector can hold 512 bytes of data. 

A block, on the other hand, is a group of sectors that the operating system can address (point to). A block might be one sector, or it might be several sectors (2,4,8, or even 16). The bigger the drive, the more sectors that a block will hold. 

So why are there blocks. Why doesn't the operating system just point straight to the sectors? Because there are limits to the number of blocks, or drive addresses, that an operating system can address. By defining a block as several sectors, an OS can work with bigger hard drives without increasing the number of block addresses. 

True or False: When a file is copied from a hard drive to a floppy, it will usually take up less space than it takes up on a hard drive --> TRUE. 
If you tend to store lots of small files on your hard drive the blocks used to store all those little files can have a lot of wasted space in them. 
Likewise, compressing lots of little files may not save as much space on a big hard drive with a big block size 
 
Every file takes up one block no matter its size, so choosing the correct block size to efficiently consume storage can make a big difference when it comes to performance. 
For example. SQL server logs in 64 kb blocks, while Windows Server might use 4 kb blocks, and the underlying vSphere hypervisor uses 1 MB blocks. As you’ll see, the block size and IOPS have a snowballing effect on network traffic throughput. 

 

Typically Linux and Windows use a 4KB default filesystem block size. 
Even though the disk Sector size (logical/physical) shows 512 bytes, the OS filesystem IO block will be 4K. 
In a Linux machine you can verify this using the below commands: 
 
#fdisk -l /dev/(diskname) 
#cat /sys/block/sd*/queue/hw_sector_size
#cat /sys/block/sd*/queue/physical_block_size 
#stat -f filename
  File: "IOPS" ID: e68758737c7b7176 Namelen: 255 Type: ext2/ext3    Block size:   4096 Fundamental block size: 4096

For blocksize and performance, you can refer the link --> https://knowledgebase.progress.com/articles/Article/18293 

 

I find the below analogy quite easy and enjoyable to understand on IOPS/Throughput (thanks to @Kgothatso Kurt -stackoverflow) 

You have 4 buckets (Disk blocks) of the same size that you want to fill or empty water. You'll be using a jug to transfer the water into the buckets. 

Now your question will be : 

At a given time (per second), how many jugs of water can you pour(write) or withdraw (read)? This is IOPS 

At a given time (per second) what's the amount(bit, kb, mb, ect) of water the jug can transfer into/out of the bucket continuously? This is throughput. 

Additionally, there is a delay in the process of you pouring and or withdrawing the water. This is Latency. 

There are 3 things to consider about IOPS and Throughput. 

- Size (file size/ block size) 
- Patterns (Random/Sequential) 
- Mix (Read/Write) percentage 
(all these factors has been explained as of now) 

 

Disk IOPS info from iostat:

In GNU/Linux, iostat is a command line tool which comes with the package systat 

iostat output on a machine with low IO usage:

# iostat
Linux 3.10.0-1062.18.1.el7.x86_64 (infra-85)     Sunday 06 December 2020     _x86_64_    (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.53    0.00    0.65    1.66    0.16   96.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              2.63         7.80        26.39  112212822  379585947


%tps : The tps number here is the number of I/O Operations Per Second (IOPS), transactions per second. 

%iowait : is first and foremost a CPU metric that measures the percentage of time the CPU is idle while waiting for an I/O operation to complete. This metric is heavily influenced by both your CPU speed and CPU load The only thing %iowait tells us for sure is that the CPU is occasionally idle and can thus handle more computational work.

 -x will give details report 

-m shows result in MB 

-d show disk utilization 

 

#iostat -dmx
Linux 3.10.0-1062.18.1.el7.x86_64 (infra-85)     Sunday 06 December 2020     _x86_64_    (2 CPU)

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.09    0.28    2.35     0.01     0.03    25.97     0.26  100.18  138.73   95.59  18.27   4.81

 

%avgqu-sz : The avgqu-sz metric is an important value. it shows the number of operations that were either queued or being serviced. Single digit numbers with the occasional double digit spike are safe(ish) values. Triple digit numbers are generally not. Note that this metric is unlikely to hover around zero unless you are doing very little I/O. A certain amount of queueing is generally unavoidable as modern storage devices reorder disk operations so as to improve overall performance. 

%await : The await metric is the average time from when a request is put in the queue to when the request is completed. Therefore, this metric is the sum of the time a request spent waiting in the queue and the time your storage device was working on servicing the request. This number is highly dependent on the number of items in the queue. Much like avgqu-sz, you'll want to have an idea of the value of this metric during normal operations for use as a reference when trouble occurs. 

%util : Percentage of elapsed time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100% for devices serving requests serially. But for devices serving requests in parallel, such as RAID arrays and modern SSDs, this number does not reflect their performance limits.

#iostat 5 2

gives 2 statistics in 5 seconds interval 

What is a good or bad number though? As with most metrics, if the first time you look at it is when you are in trouble then it’s less helpful. You should have an idea of how much IO you typically do, then if you experience issues and are doing 10x that or only getting 1/10 from the disks then you have a good candidate explanation for them.

Generally a HDD will have an IOPS range of 55-180, while a SSD will have an IOPS from 3,000 – 40,000. 

 

Below tables shows the IOPS as per the manufacturer: 

HDD's/Mechanical drives:
SSD's IOPS:

 

References: 

GNU, Unix, Linux, *nix, FOSS, F(L)OSS,..

Woah, that's a long list keywords..and yes, these are some of the basic terms that comes in the minds of programmers or sysadmins(i gues...