{"id":18918,"date":"2022-10-14T07:28:58","date_gmt":"2022-10-14T07:28:58","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=18918"},"modified":"2023-10-14T07:43:07","modified_gmt":"2023-10-14T07:43:07","slug":"use-sysbench-measure-speed-data-reads-writes-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/use-sysbench-measure-speed-data-reads-writes-linux\/","title":{"rendered":"How to Use \u2018Sysbench\u2019 to Measure the Speed of Data Reads\/Writes on Storage Devices in Linux"},"content":{"rendered":"<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-1024x768.jpg\" alt=\"How to Use SYSBENCH Utility for Storage I_O Performance Tests\" width=\"1024\" height=\"768\" class=\"alignnone size-large wp-image-18924 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-1024x768.jpg 1024w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-300x225.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-128x96.jpg 128w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-420x315.jpg 420w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-540x405.jpg 540w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-720x540.jpg 720w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-960x720.jpg 960w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-1140x855.jpg 1140w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests-1320x990.jpg 1320w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2022\/10\/How-to-Use-SYSBENCH-Utility-for-Storage-I_O-Performance-Tests.jpg 1400w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/p>\n<p>Understanding the speed at which your storage devices read and write data is crucial. This is especially true for <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-are-web-servers-and-why-are-they-needed\/\">web servers<\/a>, where the speed of data access can significantly impact user experience.<\/p>\n<p>Whether you&#8217;re using a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, or even <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a>, assessing storage I\/O performance is a must. One of the most popular tools for this purpose on Linux machines is Sysbench.<\/p>\n<p>In this tutorial, we&#8217;ll show how to use Sysbench to measure the speed of data reads\/writes on storage devices.<\/p>\n<h2>Step 1: Installing Sysbench<\/h2>\n<p>First, update your package lists:<\/p>\n<pre>\r\nsudo apt update\r\n<\/pre>\n<p>Install Sysbench:<\/p>\n<pre>\r\nsudo apt install sysbench\r\n<\/pre>\n<h2>Step 2: Running the File I\/O Test<\/h2>\n<p>Navigate to a directory where you want to run the test. For this tutorial, we&#8217;ll use the \/tmp directory:<\/p>\n<pre>\r\ncd \/tmp\r\n<\/pre>\n<p>Prepare the test environment with a test file. Let&#8217;s create a 1GB test file:<\/p>\n<pre>\r\nsysbench fileio prepare --file-total-size=1G\r\n<\/pre>\n<p>Run the file I\/O test. This will measure the speed of data reads\/writes:<\/p>\n<pre>\r\nsysbench fileio run --file-total-size=1G --file-test-mode=rndrw --time=300 --threads=4\r\n<\/pre>\n<p>Here, we&#8217;re using random reads\/writes (rndrw) for 300 seconds with 4 threads.<\/p>\n<h2>Step 3: Interpreting the Results<\/h2>\n<p>After running the test, Sysbench will provide a detailed report.<\/p>\n<p>For example:<\/p>\n<pre>\r\nsysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)\r\n\r\nRunning the test with following options:\r\nNumber of threads: 4\r\nInitializing random number generator from current time\r\n\r\nExtra file open flags: (none)\r\n128 files, 8.0MiB each\r\n1GiB total file size\r\nBlock size 16KiB\r\nNumber of IO requests: 0\r\nRead\/Write ratio for combined random IO test: 1.50\r\nPeriodic FSYNC enabled, calling fsync() each 100 requests.\r\nCalling fsync() at the end of test, Enabled.\r\nUsing synchronous I\/O mode\r\nDoing random r\/w test\r\nInitializing worker threads...\r\n\r\nThreads started!\r\n\r\nFile operations:\r\n    reads\/s:                      1654.23\r\n    writes\/s:                     1102.82\r\n    fsyncs\/s:                     3534.11\r\n\r\nThroughput:\r\n    read, MiB\/s:                  25.85\r\n    written, MiB\/s:               17.23\r\n\r\nGeneral statistics:\r\n    total time:                          300.0143s\r\n    total number of events:              1049231\r\n\r\nLatency (ms):\r\n         min:                                  0.00\r\n         avg:                                  1.14\r\n         max:                                 23.45\r\n         95th percentile:                      2.67\r\n         sum:                             1195234.23\r\n\r\nThreads fairness:\r\n    events (avg\/stddev):           262307.7500\/1205.31\r\n    execution time (avg\/stddev):   298.8081\/0.01\r\n<\/pre>\n<p>Look for the following key metrics:<\/p>\n<ul>\n<li><span class=\"fw-bold\">Read\/write requests:<\/span> Number of read and write operations performed.<\/li>\n<li><span class=\"fw-bold\">Throughput:<\/span> Amount of data read\/written per second.<\/li>\n<li><span class=\"fw-bold\">Average request time:<\/span> Average time taken for read\/write requests.<\/li>\n<\/ul>\n<p>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.<\/p>\n<ol>\n<li><strong>File Operations<\/strong>:\n<ul>\n<li><strong>reads\/s<\/strong>: The system performed an average of <strong>1654.23 read operations per second<\/strong>. This indicates how many times the system read from the storage device in one second.<\/li>\n<li><strong>writes\/s<\/strong>: The system performed an average of <strong>1102.82 write operations per second<\/strong>. This shows how many times data was written to the storage device in one second.<\/li>\n<li><strong>fsyncs\/s<\/strong>: The system called the <code>fsync<\/code> function <strong>3534.11 times per second<\/strong>. This function is used to synchronize a file&#8217;s in-core state with storage device, ensuring data integrity.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Throughput<\/strong>:\n<ul>\n<li><strong>read, MiB\/s<\/strong>: The system read data at an average rate of <strong>25.85 MiB\/s<\/strong>. This metric indicates the volume of data read from the storage device every second.<\/li>\n<li><strong>written, MiB\/s<\/strong>: The system wrote data at an average rate of <strong>17.23 MiB\/s<\/strong>. This denotes the volume of data written to the storage device every second.<\/li>\n<\/ul>\n<\/li>\n<li><strong>General Statistics<\/strong>:\n<ul>\n<li><strong>total time<\/strong>: The test ran for <strong>300.0143 seconds<\/strong>.<\/li>\n<li><strong>total number of events<\/strong>: During the test, <strong>1,049,231 events<\/strong> (read, write, fsync operations) occurred.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Latency (ms)<\/strong>:\n<ul>\n<li><strong>avg<\/strong>: On average, each I\/O operation had a latency of <strong>1.14 milliseconds<\/strong>. This is the time taken between the request for a read\/write operation and its completion.<\/li>\n<li><strong>max<\/strong>: The longest time taken for a single I\/O operation was <strong>23.45 milliseconds<\/strong>.<\/li>\n<li><strong>95th percentile<\/strong>: 95% of the I\/O operations were completed in <strong>2.67 milliseconds<\/strong> or less. This metric helps in understanding the distribution of latencies and identifying outliers.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Threads Fairness<\/strong>:\n<ul>\n<li><strong>events (avg\/stddev)<\/strong>: On average, each of the 4 threads handled <strong>262,307.75 events<\/strong>, with a standard deviation of <strong>1205.31<\/strong>. This indicates that the workload was fairly evenly distributed among the threads.<\/li>\n<li><strong>execution time (avg\/stddev)<\/strong>: Each thread, on average, executed for <strong>298.8081 seconds<\/strong> with a very minimal standard deviation of <strong>0.01<\/strong>. This further confirms the even distribution of workload.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>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.<\/p>\n<h2>Step 4: Cleaning Up<\/h2>\n<p>After the test, it&#8217;s a good practice to clean up the test files:<\/p>\n<pre>\r\nsysbench fileio cleanup\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo apt update<\/span> \u2013 Updates the package lists for upgrades and new packages.<\/li>\n<li><span class=\"fw-bold\">sudo apt install sysbench<\/span> \u2013 Installs Sysbench.<\/li>\n<li><span class=\"fw-bold\">sysbench fileio prepare<\/span> \u2013 Prepares the test environment with a test file.<\/li>\n<li><span class=\"fw-bold\">sysbench fileio run<\/span> \u2013 Runs the file I\/O test.<\/li>\n<li><span class=\"fw-bold\">sysbench fileio cleanup<\/span> \u2013 Cleans up the test files after the test.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is Sysbench?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n            <span itemprop=\"text\">Sysbench is a modular, cross-platform, and multi-threaded benchmark tool designed to evaluate and test various parameters of a system&#8217;s performance, including CPU, memory, and I\/O.<\/span>\n        <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why is storage I\/O performance important?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n            <span itemprop=\"text\">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.<\/span>\n        <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How can I improve my storage I\/O performance?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n            <span itemprop=\"text\">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.<\/span>\n        <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Can Sysbench be used on other operating systems besides Linux?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n            <span itemprop=\"text\">Yes, Sysbench is cross-platform and can be used on various operating systems, including Linux, Windows, and macOS.<\/span>\n        <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Is there any cost associated with using Sysbench?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n            <span itemprop=\"text\">No, Sysbench is open-source software and is freely available for use.<\/span>\n        <\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>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&#8217;s capabilities and make informed decisions about potential upgrades or optimizations. Whether you&#8217;re running a <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a>, or <a href=\"https:\/\/webhostinggeeks.com\/blog\/litespeed-web-server-explained\/\">LiteSpeed<\/a> server, understanding your storage I\/O performance is crucial for delivering the best user experience.<\/p>\n<p>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.<\/p>\n<p>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&#8217;s performance.<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":6,"featured_media":18924,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2152],"tags":[2172,2153],"class_list":["post-18918","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-benchmarking","tag-sysbench","tag-test"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/18918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=18918"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/18918\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/18924"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=18918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=18918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=18918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}