Redis performs performance tests

  • 2020-10-23 20:20:58
  • OfStack

The Redis performance test was achieved by executing multiple commands simultaneously.

grammar

The basic commands for redis performance testing are as follows:

[

redis-benchmark [option] [option value]

]

Note: This command is executed in the directory of redis, not the internal instruction of the redis client.

The instance

The following instances execute 10,000 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 test tool are as follows:

序号 选项 描述 默认值
1 -h 指定服务器主机名 127.0.0.1
2 -p 指定服务器端口 6379
3 -s 指定服务器 socket
4 -c 指定并发连接数 50
5 -n 指定请求数 10000
6 -d 以字节的形式指定 SET/GET 值的数据大小 2
7 -k 1=keep alive 0=reconnect 1
8 -r SET/GET/INCR 使用随机 key, SADD 使用随机值
9 -P 通过管道传输 <numreq> 请求 1
10 -q 强制退出 redis。仅显示 query/sec 值
11 --csv 以 CSV 格式输出
12 -l 生成循环,永久执行测试
13 -t 仅运行以逗号分隔的测试命令列表。
14 -I Idle 模式。仅打开 N 个 idle 连接并等待。

The instance

We used multiple parameters to test redis performance in the following example:

[

$ 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 above example, the host is 127.0.0.1, the port number is 6379, the command executed is set,lpush, the number of requests is 10000, and the result only shows the number of requests executed per second through the -ES46en parameter.

That's how Redis performs performance tests. For more information on redis performance tests, check out the other articles on this site!


Related articles: