【Redis学习系列】压力测试

/ Redis / 没有评论 / 1110浏览

Redis压力测试

redis 自带压力测试工具 redis-benchmark

注意:该命令是在 redis 的目录下执行的,而不是 redis 客户端的内部指令

redis 性能测试工具可选参数如下所示:

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

根据以上命令参数;我们来实操测试一下。

root@AY140210092026Z:~/redis# redis-benchmark -h 127.0.0.1 -p 6379 -c 50 -n 10000
====== PING_INLINE ======
  10000 requests completed in 0.34 seconds   # 0.34秒完成了1万请求
  50 parallel clients #50个客户端并发
  3 bytes payload
  keep alive: 1 #一个线程
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

0.01% <= 0.3 milliseconds
2.02% <= 0.4 milliseconds
7.68% <= 0.5 milliseconds
16.65% <= 0.6 milliseconds
28.40% <= 0.7 milliseconds
40.69% <= 0.8 milliseconds
52.58% <= 0.9 milliseconds
63.64% <= 1.0 milliseconds
73.20% <= 1.1 milliseconds
80.77% <= 1.2 milliseconds
86.52% <= 1.3 milliseconds
91.79% <= 1.4 milliseconds
95.43% <= 1.5 milliseconds
96.84% <= 1.6 milliseconds
97.19% <= 1.7 milliseconds
97.44% <= 1.8 milliseconds
97.58% <= 1.9 milliseconds
97.73% <= 2 milliseconds
98.82% <= 3 milliseconds
99.28% <= 4 milliseconds
99.86% <= 5 milliseconds
99.88% <= 6 milliseconds
100.00% <= 6 milliseconds   # 6毫秒 完成了100%
28985.51 requests per second

====== PING_BULK ======
  10000 requests completed in 0.34 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

64.90% <= 1 milliseconds
98.77% <= 2 milliseconds
99.60% <= 3 milliseconds
99.85% <= 4 milliseconds
99.98% <= 5 milliseconds
100.00% <= 5 milliseconds
29761.90 requests per second

====== SET ======
  10000 requests completed in 0.33 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

61.77% <= 1 milliseconds
98.86% <= 2 milliseconds
100.00% <= 2 milliseconds
30303.03 requests per second

====== GET ======
  10000 requests completed in 0.41 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

56.07% <= 1 milliseconds
91.89% <= 2 milliseconds
97.50% <= 3 milliseconds
98.82% <= 4 milliseconds
99.04% <= 5 milliseconds
99.34% <= 6 milliseconds
99.81% <= 7 milliseconds
99.91% <= 8 milliseconds
100.00% <= 8 milliseconds
24691.36 requests per second

====== INCR ======
  10000 requests completed in 0.32 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

67.50% <= 1 milliseconds
100.00% <= 1 milliseconds
31347.96 requests per second

====== LPUSH ======
  10000 requests completed in 0.38 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

55.09% <= 1 milliseconds
92.38% <= 2 milliseconds
98.08% <= 3 milliseconds
98.87% <= 4 milliseconds
99.82% <= 5 milliseconds
100.00% <= 5 milliseconds
26041.67 requests per second

====== RPUSH ======
  10000 requests completed in 0.34 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

62.80% <= 1 milliseconds
97.65% <= 2 milliseconds
99.23% <= 3 milliseconds
99.55% <= 4 milliseconds
99.83% <= 5 milliseconds
100.00% <= 5 milliseconds
29411.77 requests per second

====== LPOP ======
  10000 requests completed in 0.32 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

64.30% <= 1 milliseconds
100.00% <= 2 milliseconds
31250.00 requests per second

====== RPOP ======
  10000 requests completed in 0.35 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

61.30% <= 1 milliseconds
97.36% <= 2 milliseconds
99.56% <= 3 milliseconds
99.95% <= 4 milliseconds
99.98% <= 5 milliseconds
100.00% <= 8 milliseconds
28328.61 requests per second

====== SADD ======
  10000 requests completed in 0.33 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

66.75% <= 1 milliseconds
99.57% <= 2 milliseconds
99.63% <= 3 milliseconds
99.77% <= 4 milliseconds
99.88% <= 5 milliseconds
100.00% <= 5 milliseconds
30769.23 requests per second

====== HSET ======
  10000 requests completed in 0.35 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

61.57% <= 1 milliseconds
98.47% <= 2 milliseconds
98.90% <= 3 milliseconds
98.96% <= 4 milliseconds
99.14% <= 5 milliseconds
99.33% <= 6 milliseconds
99.65% <= 8 milliseconds
99.83% <= 10 milliseconds
100.00% <= 11 milliseconds
28571.43 requests per second

====== SPOP ======
  10000 requests completed in 0.41 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

52.06% <= 1 milliseconds
91.07% <= 2 milliseconds
97.71% <= 3 milliseconds
99.15% <= 4 milliseconds
99.63% <= 5 milliseconds
99.80% <= 6 milliseconds
100.00% <= 6 milliseconds
24154.59 requests per second

====== ZADD ======
  10000 requests completed in 0.33 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

63.83% <= 1 milliseconds
98.77% <= 2 milliseconds
99.78% <= 4 milliseconds
100.00% <= 4 milliseconds
30487.80 requests per second

====== ZPOPMIN ======
  10000 requests completed in 0.38 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

57.15% <= 1 milliseconds
92.74% <= 2 milliseconds
97.77% <= 3 milliseconds
99.03% <= 4 milliseconds
99.70% <= 5 milliseconds
100.00% <= 5 milliseconds
26455.03 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
  10000 requests completed in 0.34 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

62.52% <= 1 milliseconds
99.40% <= 2 milliseconds
99.77% <= 4 milliseconds
99.95% <= 5 milliseconds
100.00% <= 5 milliseconds
29850.75 requests per second

====== LRANGE_100 (first 100 elements) ======
  10000 requests completed in 0.60 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

5.23% <= 1 milliseconds
89.19% <= 2 milliseconds
98.76% <= 3 milliseconds
99.43% <= 4 milliseconds
99.71% <= 5 milliseconds
99.82% <= 6 milliseconds
99.93% <= 7 milliseconds
100.00% <= 7 milliseconds
16694.49 requests per second

====== LRANGE_300 (first 300 elements) ======
  10000 requests completed in 1.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

0.01% <= 2 milliseconds
82.80% <= 3 milliseconds
94.82% <= 4 milliseconds
97.29% <= 5 milliseconds
98.27% <= 6 milliseconds
98.88% <= 7 milliseconds
99.31% <= 8 milliseconds
99.63% <= 9 milliseconds
99.82% <= 10 milliseconds
99.84% <= 11 milliseconds
99.85% <= 14 milliseconds
99.89% <= 15 milliseconds
99.99% <= 16 milliseconds
100.00% <= 16 milliseconds
8176.61 requests per second

====== LRANGE_500 (first 450 elements) ======
  10000 requests completed in 1.64 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

0.01% <= 2 milliseconds
0.04% <= 3 milliseconds
81.56% <= 4 milliseconds
91.84% <= 5 milliseconds
95.04% <= 6 milliseconds
96.25% <= 7 milliseconds
97.27% <= 8 milliseconds
98.87% <= 9 milliseconds
99.21% <= 10 milliseconds
99.32% <= 11 milliseconds
99.49% <= 12 milliseconds
99.61% <= 13 milliseconds
99.63% <= 14 milliseconds
99.73% <= 15 milliseconds
99.89% <= 16 milliseconds
99.98% <= 18 milliseconds
100.00% <= 18 milliseconds
6090.13 requests per second

====== LRANGE_600 (first 600 elements) ======
  10000 requests completed in 2.08 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

0.01% <= 3 milliseconds
0.05% <= 4 milliseconds
81.08% <= 5 milliseconds
88.86% <= 6 milliseconds
92.74% <= 7 milliseconds
93.91% <= 8 milliseconds
95.39% <= 9 milliseconds
96.94% <= 10 milliseconds
98.26% <= 11 milliseconds
98.93% <= 12 milliseconds
99.24% <= 13 milliseconds
99.52% <= 14 milliseconds
99.57% <= 15 milliseconds
99.59% <= 17 milliseconds
99.80% <= 18 milliseconds
99.85% <= 19 milliseconds
99.89% <= 20 milliseconds
99.97% <= 21 milliseconds
100.00% <= 21 milliseconds
4798.46 requests per second

====== MSET (10 keys) ======
  10000 requests completed in 0.36 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no

24.08% <= 1 milliseconds
89.86% <= 2 milliseconds
97.42% <= 3 milliseconds
98.65% <= 4 milliseconds
99.41% <= 5 milliseconds
99.99% <= 6 milliseconds
100.00% <= 7 milliseconds
27855.15 requests per second

仔细阅读上面测试报告;可以看到redis的并发还是非常优秀的。