Redis压力测试说明
2016-12-28
redis-benchmark是redis自带的压力测试工具:
使用方法:
可以使用redis-benchmark –help来显示使用方法:
序号 | 选项 | 描述 | 默认值 |
---|---|---|---|
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 连接并等待。 |
例如:
> redis-benchmark -h 127.0.0.1 -p 6379 -n 10000 -q
PING_INLINE: 126582.27 requests per second
PING_BULK: 136986.30 requests per second
SET: 93457.95 requests per second
GET: 42194.09 requests per second
INCR: 113636.37 requests per second
LPUSH: 90909.09 requests per second
LPOP: 91743.13 requests per second
SADD: 123456.79 requests per second
SPOP: 128205.13 requests per second
LPUSH (needed to benchmark LRANGE): 125000.00 requests per second
LRANGE_100 (first 100 elements): 48543.69 requests per second
LRANGE_300 (first 300 elements): 20576.13 requests per second
LRANGE_500 (first 450 elements): 14306.15 requests per second
LRANGE_600 (first 600 elements): 11123.47 requests per second
MSET (10 keys): 74626.87 requests per second
表示对本地redis进行并发为50的10000次测试。
例2:
> redis-benchmark -h 127.0.0.1 -p 6379 -t get,set,lpush -n 10000 -q
只测试get,set,lpush操作。
基准测试
ThinkPad E14
C:\Users\malu>redis-benchmark -h 127.0.0.1 -p 6379 -n 10000 -q
PING_INLINE: 79365.08 requests per second
PING_BULK: 82644.63 requests per second
SET: 81967.21 requests per second
GET: 78740.16 requests per second
INCR: 78125.00 requests per second
LPUSH: 80645.16 requests per second
RPUSH: 83333.34 requests per second
LPOP: 80645.16 requests per second
RPOP: 92592.59 requests per second
SADD: 100000.00 requests per second
SPOP: 102040.82 requests per second
LPUSH (needed to benchmark LRANGE): 95238.10 requests per second
LRANGE_100 (first 100 elements): 33898.30 requests per second
LRANGE_300 (first 300 elements): 14326.65 requests per second
LRANGE_500 (first 450 elements): 9784.74 requests per second
LRANGE_600 (first 600 elements): 7806.40 requests per second
MSET (10 keys): 90909.09 requests per second
单核:Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
[ root@php72:~ ]$ redis-benchmark -h 127.0.0.1 -p 6379 -n 10000 -q
PING_INLINE: 46948.36 requests per second
PING_BULK: 57142.86 requests per second
SET: 63291.14 requests per second
GET: 57471.27 requests per second
INCR: 65359.48 requests per second
LPUSH: 66225.17 requests per second
RPUSH: 64102.56 requests per second
LPOP: 66225.17 requests per second
RPOP: 65789.48 requests per second
SADD: 64935.07 requests per second
HSET: 66225.17 requests per second
SPOP: 64516.13 requests per second
LPUSH (needed to benchmark LRANGE): 29585.80 requests per second
LRANGE_100 (first 100 elements): 32786.88 requests per second
LRANGE_300 (first 300 elements): 13175.23 requests per second
LRANGE_500 (first 450 elements): 8176.61 requests per second
LRANGE_600 (first 600 elements): 5678.59 requests per second
MSET (10 keys): 49751.24 requests per second
8核:Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
root@iZ28ygxxh8fZ:~# redis-benchmark -h 127.0.0.1 -p 6379 -n 10000 -q
PING_INLINE: 88495.58 requests per second
PING_BULK: 97087.38 requests per second
SET: 76335.88 requests per second
GET: 72992.70 requests per second
INCR: 74074.07 requests per second
LPUSH: 78125.00 requests per second
LPOP: 75187.97 requests per second
SADD: 71428.57 requests per second
SPOP: 71942.45 requests per second
LPUSH (needed to benchmark LRANGE): 72992.70 requests per second
LRANGE_100 (first 100 elements): 38910.51 requests per second
LRANGE_300 (first 300 elements): 13642.57 requests per second
LRANGE_500 (first 450 elements): 13812.16 requests per second
LRANGE_600 (first 600 elements): 11454.75 requests per second
MSET (10 keys): 69444.45 requests per second