How to test the disk speed and RAM of your Linux server

Contents

server rack installation

If you write or read files regularly, the speed of your disk can affect the performance of your server. We'll show you how to measure your server speed and understand how it stacks up against the competition.

How do you measure IO performance?

There are many different ways to read and write discs, so there is no unique number for the “speed” that you can measure.

The easiest way to measure performance is to measure the time it takes to read large files or make copies of large files. This measures the sequential read and write speed, which is a good metric to know, but you will rarely see such high speeds in practice, especially in a server environment.

A better metric is random access speed, which measures how fast you can get into files stored in random blocks, much more mimicking real world usage.

List of read and write speeds.

SSDs typically have fast random access speeds compared to hard drives, which makes them much more suitable for general use. Hard drives still have decent sequential read and write speeds, which makes them good for data archiving and recovery.

Despite this, disk performance may not matter much for certain workloads. Many applications cache objects (if you have enough RAM), so the next time you want to read that object, will be read from memory (which is faster). Despite this, for write-intensive workloads, disk still needs to be entered.

Speed ​​is often measured in MB / s, but some vendors can measure on IOPS (input operations / output per second). This is simply a larger number that means the same thing.; can find out what MB IOPS / s with this formula:

IOPS = (MBps / Block Size) * 1024

Despite this, some vendors may not do a good job of telling you which benchmark they use to measure IOPS, so it is good that you do it yourself.

Install fio for reading tests / random writing

Although Linux has built-in dd , which can be used to measure sequential write performance, not indicative of how it will behave under real world stresses. Instead, you'll want to test your random read and write speed.

fio is a utility that can handle this. Install it from the package manager of your distribution:

sudo apt-get install fio

Subsequently, run a basic test with the following command:

fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=random_read_write.fio --bs=4k --iodepth=64 --size=250M --readwrite=randrw --rwmixread=80

This runs random read and write tests using 250 MB of data, in a ratio of 80% from readings to 20% of deeds. Results will be displayed in terms of IOPS and MB / s:

The above test ran on an AWS gp2 SSD, a fairly average SSD, showing a fairly average performance. Write performance will always be lower with any type of E / S; many SSDs and HDDs have built-in cache memory for use by the drive controller, which makes many reads quite fast. Despite this, whenever I write, you must make physical changes to the unit, which is slower.

Running the test on a hard drive shows poor E performance / Random mixed s, which is a common obstacle with hard drives:

fio hard drive test results

Despite this, hard drives are regularly used for large sequential reads and writes, so an E test / Random S does not match the use case here. If you want to change the type of test, you can pass a different argument to --readwrite. fio supports many different tests:

  • Sequential reading: seqread
  • Sequential write:seqwrite
  • Random read: randread
  • Random write: randwrite
  • Random mixed IO: randrw

At the same time, you can resize the block with the --bs argument. We set it to 4K, which is pretty standard for random tests, but sequential reads and writes may show better or worse performance with larger block sizes. The sizes of 16 KB a 32 KB may be closer to what you will find under actual load.

Memory performance test

fio can't test ram speed, so if you want to compare your server RAM, must install sysbench from your distribution's package manager:

sudo apt-get install sysbench

This package can compare many performance metrics, but we only focus on the memory test. The following command assigns 1 MB de RAM, then it performs write operations until it has written 10 GB of data (do not worry, does not need 10 GB of RAM to perform this benchmark).

sysbench --test=memory --memory-block-size=1M --memory-total-size=10G run

This will show the memory speed in MiB / s, as well as the access latency associated with it.

Memory speed test results in MiB / s, as well as the access latency associated with it.

This test measures writing speed, but you can add --memory-oper=read to measure the reading speed, which should be a little higher most of the time. You can also try lower block sizes, what puts more pressure on memory.

Despite this, realistically, most of the RAM will be good enough to run just about anything, and in general you will be more limited by the amount of RAM than by the actual speed.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.