Overview
Redis-benchmark is an official Redis Performance Testing tool provided by Redis. It can effectively test the performance of Redis services. This topic describes the relevant information.
Details
Redis-benchmark instructions
The following table describes the Redis-benchmark parameters.
Usage: redis-benchmark [-h] [-p] [-c] [-n[-k] -h Server hostname (default 127.0.0.1) -p Server port (default 6379) -s Server socket (overrides host and port) -c Number of parallel connections (default 50) -n Total number of requests (default 10000) -d Data size of SET/GET value in bytes (default 2) -k 1=keep alive 0=reconnect (default 1) -r Use random keys for SET/GET/INCR, random values for SADD Using this option the benchmark will get/set keys in the form mykey_rand:000000012456 instead of constant keys, the argument determines the max number of values for the random number. For instance if set to 10 only rand:000000000000 - rand:000000000009 range will be allowed. -P Pipelinerequests. Default 1 (no pipeline). -q Quiet. Just show query/sec values --csv Output in CSV format -l Loop. Run the tests forever -t Only run the comma-separated list of tests. The test names are the same as the ones produced as output. -I Idle mode. Just open N idle connections and wait.
Sample statement
The following example shows how to use the Redis-benchmark command.
- As shown in the following command, 100 concurrent connections and 100000 requests are used to detect the performance of Redis servers with 6379 ports.
redis-benchmark -h 192.X.X.201 -p 6379 -c 100 -n 100000
- As shown in the following command, test the performance of obtaining packets with a size of 100 bytes.
redis-benchmark -h X.X.X.X -p 6379 -q -d 100
- As shown in the following command, only the performance of some operations is tested.
redis-benchmark -t set,lpush -n 100000 -q
- As shown in the following command, only the performance of partial numerical access is tested.
redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')"
Example
- Run the following command to perform the test:
redis-benchmark -h X.X.X.X -p 18000 -c 5000 -n 100000 -q
If an output similar to the following one is displayed, Python is installed. - Run the
netstat -an
command to check whether there are many ports related to Redis. If there are many connections, restart the ApsaraDB for Redis instance and release the connections. Then, test again.
Applicable scope
- ApsaraDB for Redis