Redis-Benchmark
大约 2 分钟
1. 常用参数
选项 | 说明 | 默认值 |
---|---|---|
-h | 服务器名 | 127.0.0.1 |
-p | 端口 | 6379 |
-c | 并发 | 50 |
-n | 请求数 | 10000 |
-d | SET/GET值的大小 | 2 |
-k | 1=keep alive, 0=reconnect | 1 |
-a | 后接密码 |
2. 输出分析
使用redis-benchmark -c 100 -n 100000
命令测试一下性能,会输出所有的性能分析,以其中的SET为例,看一下输出的意义
====== SET ======
# 请求数 和 完成时间
100000 requests completed in 6.69 seconds
# 并发数
100 parallel clients
# 字节大小
3 bytes payload
# 节点个数
keep alive: 1
host configuration "save": 3600 1 300 100 60 10000
host configuration "appendonly": no
multi-thread: no
Latency by percentile distribution:
0.000% <= 1.887 milliseconds (cumulative count 1)
50.000% <= 3.119 milliseconds (cumulative count 50055)
75.000% <= 4.055 milliseconds (cumulative count 75092)
87.500% <= 4.527 milliseconds (cumulative count 87848)
93.750% <= 4.695 milliseconds (cumulative count 93759)
96.875% <= 4.959 milliseconds (cumulative count 96908)
98.438% <= 5.247 milliseconds (cumulative count 98452)
99.219% <= 5.391 milliseconds (cumulative count 99219)
99.609% <= 5.783 milliseconds (cumulative count 99612)
99.805% <= 6.023 milliseconds (cumulative count 99818)
99.902% <= 6.103 milliseconds (cumulative count 99905)
99.951% <= 6.199 milliseconds (cumulative count 99954)
99.976% <= 6.359 milliseconds (cumulative count 99977)
99.988% <= 8.071 milliseconds (cumulative count 99988)
99.994% <= 8.599 milliseconds (cumulative count 99994)
99.997% <= 8.951 milliseconds (cumulative count 99997)
99.998% <= 9.095 milliseconds (cumulative count 99999)
99.999% <= 9.167 milliseconds (cumulative count 100000)
100.000% <= 9.167 milliseconds (cumulative count 100000)
Cumulative distribution of latencies:
0.000% <= 0.103 milliseconds (cumulative count 0)
0.002% <= 1.903 milliseconds (cumulative count 2)
0.018% <= 2.007 milliseconds (cumulative count 18)
0.230% <= 2.103 milliseconds (cumulative count 230)
49.901% <= 3.103 milliseconds (cumulative count 49901)
76.104% <= 4.103 milliseconds (cumulative count 76104)
97.435% <= 5.103 milliseconds (cumulative count 97435)
99.905% <= 6.103 milliseconds (cumulative count 99905)
99.983% <= 7.103 milliseconds (cumulative count 99983)
99.988% <= 8.103 milliseconds (cumulative count 99988)
99.999% <= 9.103 milliseconds (cumulative count 99999)
100.000% <= 10.103 milliseconds (cumulative count 100000)
# 每秒性能
Summary:
throughput summary: 14949.92 requests per second
latency summary (msec):
avg min p50 p95 p99 max
3.364 1.880 3.119 4.759 5.335 9.167
这里发现了一个有趣的问题, 手头有三个可以测试的redis, 均是使用docker(x86)启动,版本都是redis:7.0.10(x86)
, redis.conf也一样,但是测试的结果显示理论性能最强的服务器反而效果不好, 暂时还没找到原因,先取一下set的结果记录一下
# CentOS7 - 4G - 2C(2.5Ghz)
Summary:
throughput summary: 72306.58 requests per second
latency summary (msec):
avg min p50 p95 p99 max
0.720 0.168 0.711 0.871 1.591 5.015
# ubuntu18.04 - 16G - 8C(2.8Ghz-4.7Ghz)
Summary:
throughput summary: 212765.95 requests per second
latency summary (msec):
avg min p50 p95 p99 max
0.239 0.080 0.223 0.303 0.719 2.079
# CentOS7 - 32G - 12C(2.9Ghz)
Summary:
throughput summary: 13730.61 requests per second
latency summary (msec):
avg min p50 p95 p99 max
3.658 1.824 4.039 4.871 5.223 6.711
看网上说Redis的瓶颈在于内存,不在CPU,所以感觉可能是32G的内存条速度太低了?