Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Performance Testing

Redis Performance Testing

Redis performance testing is achieved by executing multiple commands simultaneously.

Syntax

The basic command for redis performance testing is as follows:



redis-benchmark [option] [option value]

Note: this command is executed in the redis directory, not as an internal command of the redis client.

Example

The following example executes 10000 requests simultaneously to test performance:



$ redis-benchmark -n 10000  -q



PING_INLINE: 141043.72 requests per second

PING_BULK: 142857.14 requests per second

SET: 141442.72 requests per second

GET: 145348.83 requests per second

INCR: 137362.64 requests per second

LPUSH: 145348.83 requests per second

LPOP: 146198.83 requests per second

SADD: 146198.83 requests per second

SPOP: 149253.73 requests per second

LPUSH (needed to benchmark LRANGE): 148588.42 requests per second

LRANGE_100 (first 100 elements): 58411.21 requests per second

LRANGE_300 (first 300 elements): 21195.42 requests per second

LRANGE_500 (first 450 elements): 14539.11 requests per second

LRANGE_600 (first 600 elements): 10504.20 requests per second

MSET (10 keys): 93283.58 requests per second

The optional parameters of the redis performance testing tool are as follows:

No. Option Description Default value
1 -h Specify server hostname 127.0.0.1
2 -p Specify server port 6379
3 -s Specify server socket
4 -c Specify number of parallel connections 50
5 -n Specify total requests 10000
6 -d Specify data size of SET/GET values in bytes 2
7 -k 1=keep alive 0=reconnect 1
8 -r SET/GET/INCR use random keys, SADD uses random values
9 -P Use pipelining requests 1
10 -q Force quit redis. Only show query/sec value
11 --csv Output in CSV format
12 -l(lowercase letter L) Generate a loop and run the test forever
13 -t Only run the comma-separated list of test commands.
14 -I(uppercase letter I) Idle mode. Only open N idle connections and wait.

Example

In the following example we used several parameters to test redis performance:



$ redis-benchmark -h 127.0.0.1 -p 6379 -t set,lpush -n 10000 -q



SET: 146198.83 requests per second

LPUSH: 145560.41 requests per second

In the example above, the host is 127.0.0.1, the port is 6379, the commands executed are set and lpush, the total requests are 10000, and the -q parameter makes the result show only the number of requests executed per second.