Redis - Benchmarks
Redis - Benchmarking Performance
Section titled “Redis - Benchmarking Performance”Redis includes a built-in benchmarking utility, redis-benchmark, designed to simulate running multiple commands from multiple parallel clients. It provides a standardized way to measure the performance of your Redis instance under a synthetic load.
Syntax
Section titled “Syntax”The basic syntax for running the benchmark utility from your terminal is:
redis-benchmark [options]Running a Default Benchmark
Section titled “Running a Default Benchmark”Executing redis-benchmark without any options runs a standard suite of tests using 50 parallel clients and 100,000 total requests.
$ redis-benchmark
====== PING_INLINE ====== 100000 requests completed in 0.70 seconds 50 parallel clients 3 bytes payload keep alive: 1
99.68% <= 1 milliseconds100.00% <= 1 milliseconds142653.36 requests per second
====== PING_BULK ====== 100000 requests completed in 0.69 seconds 50 parallel clients 3 bytes payload keep alive: 1
99.78% <= 1 milliseconds100.00% <= 1 milliseconds144717.80 requests per second
... (output continues for SET, GET, LPUSH, etc.) ...
====== MSET (10 keys) ====== 100000 requests completed in 1.15 seconds 50 parallel clients 3 bytes payload keep alive: 1
96.48% <= 1 milliseconds99.88% <= 2 milliseconds100.00% <= 2 milliseconds87108.02 requests per secondCustomizing the Benchmark
Section titled “Customizing the Benchmark”You can tailor the benchmark to better reflect your application’s workload using various options. For example, let’s test only SET and GET commands with a larger data payload.
# -n 100000: 100,000 total requests# -c 100: 100 parallel clients# -d 256: 256 bytes data payload for SET/GET# -t get,set: Only run GET and SET tests# -q: Quiet mode, shows only req/sec
$ redis-benchmark -n 100000 -c 100 -d 256 -t get,set -q
SET: 121951.22 requests per secondGET: 123001.23 requests per secondKey Benchmark Options
Section titled “Key Benchmark Options”Below is a table of the most commonly used options for redis-benchmark.
| Option | Description | Default Value |
|---|---|---|
| -h | Server hostname. | 127.0.0.1 |
| -p | Server port. | 6379 |
| -a | Password for authentication. | None |
| -c | Number of parallel connections (clients). | 50 |
| -n | Total number of requests to perform. | 100000 |
| -d | Data size of SET/GET values in bytes. | 3 |
| -t | Comma-separated list of tests to run (e.g., set,get,lpush). | All tests |
| -P | Pipeline | 1 |
| -k | Use persistent connections (1=yes, 0=no). | 1 |
| -r | Use random keys for SET/GET/INCR from a keyspace of size | Not set |
| -q | Quiet mode. Shows only the final queries/sec summary. | Disabled |
| —csv | Output results in CSV format. | Disabled |
Best Practices and Interpretation
Section titled “Best Practices and Interpretation”- DO NOT Run on Production:
redis-benchmarkcan saturate the CPU and network, severely impacting the performance of your live application. Always run it on a dedicated test server with identical hardware and network configuration to production. - Simulate Real Workloads: The default benchmark is generic. Use the
-t,-d, and-coptions to mimic your application’s specific command patterns, data sizes, and concurrency levels for a more accurate assessment. - Test Pipelining: Use the
-Poption to see the significant performance boost from pipelining. For example,-P 16will send commands in batches of 16. - It’s a Baseline: Benchmark results are a baseline, not an absolute guarantee of real-world performance. Application logic, network fluctuations, and other factors will have an impact. Use it to compare configurations, hardware, or Redis versions.