Redis Benchmarking Commands
Redis Benchmarks support several options and commands to tailor your performance tests. Here are some of the most commonly used ones:
Hostname command
Specifies the hostname or IP address of the Redis server to connect. The default is 127.0.0.1.
Syntax:
-h, –host <hostname>
Example:
Connect to a Redis server running on 192.162.4.100
redis-benchmark -h 192.162.4.100
This option allows you to specify the hostname or IP address of the Redis server to which you want to connect. By default, it is set to 127.0.0.1, which means it will connect to a Redis server running on the local machine. You can change this to the hostname or IP address of your Redis server if it’s on a remote machine.
Port command
Specifies the port number of the Redis server.
Syntax:
-p, –port <port>
Example:
Connect to a Redis server running on port 6380
redis-benchmark -p 6380
This option to specify the port number of the Redis server. The default Redis port is 6379. If your Redis server is running on a different port, you can provide that port number using this option.
Client Number command
Sets the number of parallel client connections to use for the benchmark.
Syntax:
-c, –clients <num>
Example:
Simulate 500 clients making requests concurrently
redis-benchmark -c 500
It determines the number of parallel client connections that Redis Benchmark will use to simulate the workload. Increasing the number of clients can help you test how well Redis handles concurrent requests.
Requests command
Determines the total number of requests to send during the benchmark.
Syntax:
-n, –requests <num>:
Example:
Each client sends 50,000 requests.
redis-benchmark -n 50000
This option sets the total number of requests that each client connection will send during the benchmark. It represents the workload you want to simulate.
Threads command
Specifies the number of threads to use for running the benchmark.
Syntax:
-t, –threads <num>
The -t option specifies the number of threads to use for running the benchmark.
Note: Redis Benchmark supports multi-threaded benchmarking, which can help you saturate your CPU cores effectively. This is particularly useful for high-performance servers with multiple CPU cores.
Example:
Run the benchmark using 4 threads
redis-benchmark -t 4
Data Size command
Sets the size of the payload for SET and GET operations.
Syntax:
-d, –data-size <num>:
With this option, you can set the size of the payload data for SET and GET operations. The default is 2 bytes.
Example:
d 512 would set the payload size to 512 bytes.
-d, –data-size 512
Random Benchmarking Data command
Redis Benchmark will randomize the payload data for SET and GET operations. This is useful for testing scenarios where the data is not predictable or uniform.
Syntax:
-r, –random-data:
Example: Use a 256-byte payload for SET and GET operations
redis-benchmark -d 256
Key Benchmark command:
It helps for simulating real-world scenarios where keys follow a specific structure.
Syntax:
-k, –key-pattern <pattern>
The -k option allows you to specify a key pattern for benchmarking. For instance, -k “user:%u:profile” uses %u as a placeholder for unique values in keys.
Example:
Simulate keys in the format “user:580097:profile”:
redis-benchmark -k “user:%u:profile”
Pipeline command:
Enables pipelining of commands, allowing multiple commands to be sent in a single network request.
Syntax:
-o, –pipeline <num>
Enabling pipelining with this option allows you to send multiple commands in a single network request. It can significantly improve Redis’s throughput by reducing the overhead of individual command execution.
Example:
-o 1 means each client will send one command at a time, while -o 10 means each client will send ten commands in a single request.
-o, –pipeline 1
Request command:
Syntax:
redis-benchmark -n <num>
Example:
redis-benchmark -n 50000
Note: Ensure the total number of requests doesn’t overload the server or take too long to complete.
Example:
Use pipelining with a pipeline size of 5
redis-benchmark -o 5
Note: The -o option is used to specify the number of outstanding (in-flight) requests that should be kept open at a time during the benchmarking process.
Num-Clients command:
The total number of requests.
Syntax:
redis-benchmark -n <num>
Note: Ensure the total number of requests doesn’t overload the server or take too long to complete.
Example:
To benchmark the redis for processing 1000 commands
redis-benchmark -n 1000
Complete Guide for Redis Benchmark
Redis Benchmarks, often simply referred to as redis-benchmark, is a command-line tool that allows you to measure the performance of your Redis server.
Important Topics for Redis Benchmark
- Syntax of Redis Benchmarks
- Redis Benchmarking Commands
- Redis Benchmarking Examples
- Pitfalls and Misconceptions of Redis Benchmarking
- Factors Impacting Redis Performance
- Interpreting Redis Benchmark Results
- Conclusion
It is a part of the Redis distribution, so you don’t need to install it separately. Redis Benchmarks are incredibly valuable for assessing how well your Redis server can handle various workloads, concurrent connections, and different types of operations.
Contact Us