Redis performance testing is achieved by executing multiple commands at the same time.
grammar
The basic commands for redis performance testing are as follows:
redis-benchmark [option] [option value]
Note: This command is executed in the redis directory, not the internal instructions of the redis client.
The optional parameters of the redis performance test tool are as follows:
Serial number | Options | description | Defaults |
---|---|---|---|
1 | -h | Specify the server host name | 127.0.0.1 |
2 | -p | Specify server port | 6379 |
3 | -s | Specify server socket | |
4 | -c | Specify the number of concurrent connections | 50 |
5 | -n | Specify the number of requests | 10000 |
6 | -d | Specify the data size of the SET/GET value in bytes | 2 |
7 | -k | 1=keep alive 0=reconnect | 1 |
8 | -r | SET/GET/INCR uses random keys, SADD uses random values | |
9 | -P | Pipe <numreq> requests | 1 |
10 | -q | Force redis to exit. Only display query/sec value | |
11 | --csv | Output in CSV format | |
12 | -l | Generate loops and execute tests forever | |
13 | -t | Only run a comma-separated list of test commands. | |
14 | -I | Idle mode. Only open N idle connections and wait. |
Run the benchmark test on 127.0.0.1:6379 with the default configuration:
redis-benchmark
Using 2 parallel clients for 127.0.0.1, a total of 500,000 requests:
redis-benchmark -h 127.0.0.1 -p 6379 -n 500000 -c 2
Using only the SET test, fill 127.0.0.1:6379 with approximately 1 million keys:
redis-benchmark -t set -n 1000000 -r 100000000
Benchmark 127.0.0.1:6379, several commands used to generate CSV output:
redis-benchmark -t ping,set,get -n 100000 --csv
Benchmark a specific command line:
redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0
Fill the list with 10,000 random elements:
redis-benchmark -r 10000 -n 10000 lpush mylist rand_int