How to Use ‘Sysbench’ to Measure the Speed of Data Reads/Writes on Storage Devices in Linux

How to Use SYSBENCH Utility for Storage I_O Performance Tests

Understanding the speed at which your storage devices read and write data is crucial. This is especially true for web servers, where the speed of data access can significantly impact user experience.

Whether you’re using a dedicated server, a VPS server, or even cloud hosting, assessing storage I/O performance is a must. One of the most popular tools for this purpose on Linux machines is Sysbench.

In this tutorial, we’ll show how to use Sysbench to measure the speed of data reads/writes on storage devices.

Step 1: Installing Sysbench

First, update your package lists:

sudo apt update

Install Sysbench:

sudo apt install sysbench

Step 2: Running the File I/O Test

Navigate to a directory where you want to run the test. For this tutorial, we’ll use the /tmp directory:

cd /tmp

Prepare the test environment with a test file. Let’s create a 1GB test file:

sysbench fileio prepare --file-total-size=1G

Run the file I/O test. This will measure the speed of data reads/writes:

sysbench fileio run --file-total-size=1G --file-test-mode=rndrw --time=300 --threads=4

Here, we’re using random reads/writes (rndrw) for 300 seconds with 4 threads.

Step 3: Interpreting the Results

After running the test, Sysbench will provide a detailed report.

For example:

sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time

Extra file open flags: (none)
128 files, 8.0MiB each
1GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...

Threads started!

File operations:
    reads/s:                      1654.23
    writes/s:                     1102.82
    fsyncs/s:                     3534.11

Throughput:
    read, MiB/s:                  25.85
    written, MiB/s:               17.23

General statistics:
    total time:                          300.0143s
    total number of events:              1049231

Latency (ms):
         min:                                  0.00
         avg:                                  1.14
         max:                                 23.45
         95th percentile:                      2.67
         sum:                             1195234.23

Threads fairness:
    events (avg/stddev):           262307.7500/1205.31
    execution time (avg/stddev):   298.8081/0.01

Look for the following key metrics:

  • Read/write requests: Number of read and write operations performed.
  • Throughput: Amount of data read/written per second.
  • Average request time: Average time taken for read/write requests.
See also  How to Use TPC-C to Test Database Performance on a Linux Machine

In our example the test was conducted using 4 threads over a duration of 300 seconds (5 minutes) on a total file size of 1GiB.

  1. File Operations:
    • reads/s: The system performed an average of 1654.23 read operations per second. This indicates how many times the system read from the storage device in one second.
    • writes/s: The system performed an average of 1102.82 write operations per second. This shows how many times data was written to the storage device in one second.
    • fsyncs/s: The system called the fsync function 3534.11 times per second. This function is used to synchronize a file’s in-core state with storage device, ensuring data integrity.
  2. Throughput:
    • read, MiB/s: The system read data at an average rate of 25.85 MiB/s. This metric indicates the volume of data read from the storage device every second.
    • written, MiB/s: The system wrote data at an average rate of 17.23 MiB/s. This denotes the volume of data written to the storage device every second.
  3. General Statistics:
    • total time: The test ran for 300.0143 seconds.
    • total number of events: During the test, 1,049,231 events (read, write, fsync operations) occurred.
  4. Latency (ms):
    • avg: On average, each I/O operation had a latency of 1.14 milliseconds. This is the time taken between the request for a read/write operation and its completion.
    • max: The longest time taken for a single I/O operation was 23.45 milliseconds.
    • 95th percentile: 95% of the I/O operations were completed in 2.67 milliseconds or less. This metric helps in understanding the distribution of latencies and identifying outliers.
  5. Threads Fairness:
    • events (avg/stddev): On average, each of the 4 threads handled 262,307.75 events, with a standard deviation of 1205.31. This indicates that the workload was fairly evenly distributed among the threads.
    • execution time (avg/stddev): Each thread, on average, executed for 298.8081 seconds with a very minimal standard deviation of 0.01. This further confirms the even distribution of workload.
See also  How to Setup Metasploit on a Linux Machine to Perform Security Vulnerability Tests

The system showcased a balanced read and write throughput, with a slightly higher emphasis on read operations. The average latency for I/O operations was low, indicating efficient performance, with 95% of operations completing in a very acceptable time frame.

Step 4: Cleaning Up

After the test, it’s a good practice to clean up the test files:

sysbench fileio cleanup

Commands Mentioned

  • sudo apt update – Updates the package lists for upgrades and new packages.
  • sudo apt install sysbench – Installs Sysbench.
  • sysbench fileio prepare – Prepares the test environment with a test file.
  • sysbench fileio run – Runs the file I/O test.
  • sysbench fileio cleanup – Cleans up the test files after the test.

FAQ

  1. What is Sysbench?

    Sysbench is a modular, cross-platform, and multi-threaded benchmark tool designed to evaluate and test various parameters of a system’s performance, including CPU, memory, and I/O.

  2. Why is storage I/O performance important?

    Storage I/O performance is crucial as it determines how quickly data can be read from or written to storage devices. This can impact application responsiveness, database performance, and overall system efficiency.

  3. How can I improve my storage I/O performance?

    Improving storage I/O performance can be achieved by using faster storage devices, optimizing file systems, using caching mechanisms, and ensuring that storage drivers and firmware are up-to-date.

  4. Can Sysbench be used on other operating systems besides Linux?

    Yes, Sysbench is cross-platform and can be used on various operating systems, including Linux, Windows, and macOS.

  5. Is there any cost associated with using Sysbench?

    No, Sysbench is open-source software and is freely available for use.

See also  How to Test a Web Server with the MTR Command

Conclusion

Measuring the speed of data reads/writes on storage devices is essential for optimizing server performance. Sysbench offers a reliable and comprehensive method to assess storage I/O performance on Linux machines. By following this tutorial, webmasters and server administrators can effectively gauge their storage device’s capabilities and make informed decisions about potential upgrades or optimizations. Whether you’re running a Apache, Nginx, or LiteSpeed server, understanding your storage I/O performance is crucial for delivering the best user experience.

Furthermore, as the digital landscape continues to evolve, the demand for faster and more efficient storage solutions will only increase. Regularly testing and monitoring your storage I/O performance ensures that you stay ahead of potential issues, allowing you to address them proactively.

Remember, in the world of web hosting, every millisecond counts. Slow storage can lead to longer page load times, which can, in turn, affect user satisfaction and SEO rankings. By leveraging tools like Sysbench, you can ensure that your storage solutions are not the bottleneck in your system’s performance.

In the future, consider scheduling regular I/O performance tests, especially after making significant changes to your server or website. This proactive approach will help you maintain optimal performance and ensure that your users have the best experience possible when interacting with your digital platforms.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *