{"id":19005,"date":"2023-10-14T10:50:38","date_gmt":"2023-10-14T10:50:38","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=19005"},"modified":"2023-10-14T10:53:20","modified_gmt":"2023-10-14T10:53:20","slug":"how-to-use-redis-benchmark-to-test-database-performance-on-a-linux-server","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-use-redis-benchmark-to-test-database-performance-on-a-linux-server\/","title":{"rendered":"How to Use Redis-benchmark to Test Database Performance on a Linux Server"},"content":{"rendered":"<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-1024x768.jpg\" alt=\"How to Use Redis-benchmark to Assess Database Performance\" width=\"1024\" height=\"768\" class=\"alignnone size-large wp-image-19007 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-1024x768.jpg 1024w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-300x225.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-128x96.jpg 128w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-420x315.jpg 420w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-540x405.jpg 540w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-720x540.jpg 720w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-960x720.jpg 960w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-1140x855.jpg 1140w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance-1320x990.jpg 1320w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/10\/How-to-Use-Redis-benchmark-to-Assess-Database-Performance.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>Redis is a high-performance, in-memory key-value store that is widely used for caching, session storage, and other real-time applications. To ensure that Redis is operating at its peak performance, it&#8217;s crucial to benchmark its capabilities. One of the tools that Redis provides for this purpose is redis-benchmark. This tool allows users to assess the efficiency of database operations, evaluate query performance, and measure latency.<\/p>\n<p>In this guide, we will walk you through the process of using redis-benchmark on a Linux machine. By the end of this tutorial, you&#8217;ll have a clear understanding of how to test your Redis instance&#8217;s performance and interpret the results. <\/p>\n<p>Let&#8217;s get started.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>Redis installed on your Linux machine.<\/li>\n<li>Basic knowledge of Linux terminal commands.<\/li>\n<li>Root or sudo access to your Linux server.<\/li>\n<\/ul>\n<h2>Step 1. Start the Redis-benchmark Tool<\/h2>\n<p>Open your Linux terminal. If you&#8217;re accessing a remote server, you can use SSH.<\/p>\n<p>Ensure that the Redis server is running. If not, start it with the following command:<\/p>\n<pre>\r\nsudo service redis start\r\n<\/pre>\n<h2>Step 2. Run the Benchmark<\/h2>\n<p>Use the redis-benchmark command to start the benchmarking process. By default, it will perform 100,000 requests to test the performance.<\/p>\n<pre>\r\nredis-benchmark\r\n<\/pre>\n<p>Example:<\/p>\n<pre>\r\n====== PING_INLINE ======\r\n  100000 requests completed in 1.05 seconds\r\n  50 parallel clients\r\n  3 bytes payload\r\n  keep alive: 1\r\n\r\n99.97% <= 1 milliseconds\r\n100.00% <= 1 milliseconds\r\n95238.10 requests per second\r\n\r\n====== PING_BULK ======\r\n  100000 requests completed in 1.03 seconds\r\n  50 parallel clients\r\n  3 bytes payload\r\n  keep alive: 1\r\n\r\n99.96% <= 1 milliseconds\r\n100.00% <= 1 milliseconds\r\n97087.38 requests per second\r\n<\/pre>\n<h2>Step 3. Customizing the Benchmark<\/h2>\n<p>Redis-benchmark offers various options to customize the test. For instance, to perform 500,000 requests with 50 parallel connections, use:<\/p>\n<pre>\r\nredis-benchmark -n 500000 -c 50\r\n<\/pre>\n<p>Example:<\/p>\n<pre>\r\n====== PING_INLINE ======\r\n  500000 requests completed in 5.20 seconds\r\n  50 parallel clients\r\n  3 bytes payload\r\n  keep alive: 1\r\n\r\n99.95% <= 1 milliseconds\r\n100.00% <= 1 milliseconds\r\n96153.85 requests per second\r\n\r\n====== PING_BULK ======\r\n  500000 requests completed in 5.15 seconds\r\n  50 parallel clients\r\n  3 bytes payload\r\n  keep alive: 1\r\n\r\n99.94% <= 1 milliseconds\r\n100.00% <= 1 milliseconds\r\n97087.38 requests per second\r\n<\/pre>\n<h2>Step 4. Test Specific Commands<\/h2>\n<p>If you wish to test the performance of specific Redis commands, you can do so. For example, to test the SET and GET commands:<\/p>\n<pre>\r\nredis-benchmark -t set,get\r\n<\/pre>\n<p>Example:<\/p>\n<pre>\r\n====== SET ======\r\n  100000 requests completed in 1.02 seconds\r\n  50 parallel clients\r\n  3 bytes payload\r\n  keep alive: 1\r\n\r\n99.93% <= 1 milliseconds\r\n100.00% <= 1 milliseconds\r\n98039.22 requests per second\r\n\r\n====== GET ======\r\n  100000 requests completed in 1.01 seconds\r\n  50 parallel clients\r\n  3 bytes payload\r\n  keep alive: 1\r\n\r\n99.92% <= 1 milliseconds\r\n100.00% <= 1 milliseconds\r\n99009.90 requests per second\r\n<\/pre>\n<h2>Interpreting the Results<\/h2>\n<p>When you run redis-benchmark, it will provide a series of outputs that represent the performance metrics of your Redis instance. Here's how to interpret them:<\/p>\n<ul>\n<li><span class=\"fw-bold\">Throughput<\/span>: This represents the number of operations Redis can handle per second. A higher value indicates better performance.<\/li>\n<li><span class=\"fw-bold\">Latency<\/span>: This measures the time taken for an operation to complete. Lower latency values are preferable as they indicate faster response times.<\/li>\n<li><span class=\"fw-bold\">Parallel Connections<\/span>: This indicates how many operations are being performed simultaneously. It's a good metric to understand the concurrency capabilities of your Redis instance.<\/li>\n<\/ul>\n<h3>In our example:<\/h3>\n<ul>\n<li><strong>Default Test (redis-benchmark)<\/strong>: The server efficiently processed 100,000 PING operations in just 1.05 seconds, with a throughput of approximately 95,238 requests per second. This indicates a swift response time, especially given that 99.97% of these requests were processed within 1 millisecond.<\/li>\n<li><strong>Extended Test (redis-benchmark -n 500000 -c 50)<\/strong>: When the load was increased to half a million PING operations, the server showcased its scalability by completing the requests in 5.20 seconds. The throughput remained consistent at around 96,153 requests per second, demonstrating the server's ability to maintain performance under increased load.<\/li>\n<li><strong>Specific Operations Test (redis-benchmark -t set,get)<\/strong>: Focusing on fundamental Redis operations, the server exhibited a throughput of approximately 98,039 requests per second for SET operations and about 99,009 requests per second for GET operations. This distinction in speed between SET and GET operations is typical, with retrieval (GET) often being slightly faster than writing (SET).<\/li>\n<\/ul>\n<p><strong>1. <code>redis-benchmark<\/code> (Default)<\/strong><\/p>\n<ul>\n<li><strong>PING_INLINE and PING_BULK<\/strong>: These are two types of PING commands that Redis supports. The PING command is a simple operation used to check if the server is running and measure the round-trip time for messages sent from the originating client to a destination server.<\/li>\n<li><strong>100000 requests completed in 1.05 seconds<\/strong>: This means that in the span of 1.05 seconds, 100,000 PING operations were sent and responses were received.<\/li>\n<li><strong>50 parallel clients<\/strong>: This indicates that the benchmark was conducted with 50 clients connecting to the Redis server simultaneously.<\/li>\n<li><strong>3 bytes payload<\/strong>: The size of the data being sent in the PING command is 3 bytes.<\/li>\n<li><strong>99.97% &lt;= 1 milliseconds<\/strong>: This indicates that 99.97% of the requests were processed in 1 millisecond or less. This is an excellent result, showing that the Redis server is responding very quickly.<\/li>\n<li><strong>95238.10 requests per second<\/strong>: This is the throughput, indicating that the Redis server can handle approximately 95,238 PING_INLINE requests per second.<\/li>\n<\/ul>\n<p><strong>2. <code>redis-benchmark -n 500000 -c 50<\/code><\/strong><\/p>\n<ul>\n<li><strong>500000 requests completed in 5.20 seconds<\/strong>: This time, half a million PING operations were sent and processed in 5.20 seconds.<\/li>\n<li><strong>96153.85 requests per second<\/strong>: The throughput here is slightly higher than the default test, indicating that the Redis server maintained its performance even with the increased number of requests.<\/li>\n<\/ul>\n<p><strong>3. <code>redis-benchmark -t set,get<\/code><\/strong><\/p>\n<ul>\n<li><strong>SET and GET<\/strong>: These are two fundamental operations in Redis. SET is used to store a value, and GET is used to retrieve a value.<\/li>\n<li><strong>98039.22 requests per second (for SET)<\/strong>: This indicates that the Redis server can handle approximately 98,039 SET operations per second.<\/li>\n<li><strong>99009.90 requests per second (for GET)<\/strong>: Similarly, the server can handle around 99,009 GET operations per second. Typically, GET operations are slightly faster than SET operations because retrieval can be quicker than writing, especially if the data is already in memory.<\/li>\n<\/ul>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo service redis start<\/span> \u2013 Starts the Redis server.<\/li>\n<li><span class=\"fw-bold\">redis-benchmark<\/span> \u2013 Runs the default Redis benchmark test.<\/li>\n<li><span class=\"fw-bold\">redis-benchmark -n 500000 -c 50<\/span> \u2013 Customizes the benchmark test with specific requests and parallel connections.<\/li>\n<li><span class=\"fw-bold\">redis-benchmark -t set,get<\/span> \u2013 Tests specific Redis commands.<\/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 the primary purpose of redis-benchmark?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The primary purpose of redis-benchmark is to test the performance of a Redis instance, including its throughput, latency, and concurrency capabilities.<\/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 the performance of my Redis instance?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Improving Redis performance can involve optimizing configurations, ensuring adequate hardware resources, using appropriate data structures, and regularly monitoring and benchmarking the instance.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Is redis-benchmark available on all Redis installations?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Yes, redis-benchmark is a standard tool that comes bundled with Redis installations, making it readily available for performance testing.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Can I run redis-benchmark on a production server?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">While it's technically possible, it's not recommended to run redis-benchmark on a production server as it can impact the performance and availability of the server for actual users.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How often should I benchmark my Redis server?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Benchmarking frequency depends on your needs. If you make significant changes to your Redis configurations or infrastructure, it's a good idea to benchmark. Regularly scheduled benchmarks, such as monthly or quarterly, can also help track performance over time.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>Benchmarking is an essential aspect of maintaining and optimizing the performance of your Redis instance. By using redis-benchmark, you can gain valuable insights into the efficiency of your database operations and evaluate query performance and latency. Regularly conducting these tests ensures that you're getting the most out of your Redis setup. For more insights on web servers and hosting solutions, explore topics like <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">web server software<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-shared-hosting\/\">shared hosting<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, and <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a>.<\/p>\n<p>Understanding the intricacies of your Redis setup and how it interacts with your server environment is crucial. Whether you're running a small application or a large-scale web service, ensuring that your Redis instance is optimized can make a significant difference in user experience and overall system efficiency.<\/p>\n<p>Moreover, as the digital landscape evolves, so do the demands on databases and caching solutions. Regular benchmarking not only helps in identifying potential bottlenecks but also in making informed decisions about scaling and resource allocation.<\/p>\n<p>In conclusion, redis-benchmark is a powerful tool in the Redis suite that provides invaluable insights into the performance of your Redis instance. By leveraging this tool effectively and interpreting its results, you can ensure that your Redis setup is not just operational, but optimal. Regular benchmarking, combined with proactive server management and continuous learning, will ensure that your web applications run smoothly, efficiently, and remain ready for future growth.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis is a high-performance, in-memory key-value store that is widely used for caching, session storage, and other real-time applications. To ensure that Redis is operating at its peak performance, it&#8217;s&#8230;<\/p>\n","protected":false},"author":6,"featured_media":19007,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2152],"tags":[2189,2153],"class_list":["post-19005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-benchmarking","tag-redis-benchmark","tag-test"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/19005","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=19005"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/19005\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/19007"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=19005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=19005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=19005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}