最近看到新闻,Redis 在试图掌管相关的开源仓库,有很多人都提到了转投 Valkey 阵营,查询了一下,网上说 Valkey 有很多优化,特别是多线程方面的,但是搜不到具体的性能测试对比,于是自建了 Redis 和 Valkey 使用 redis-Benchmark 测试了一下。
测试环境
使用的机器是 Xeon ® Platinum 8269CY 8 核 16G 内存。
vm.overcommit_memory 设置为 1 总是允许过度分配内存。
关闭了透明大页。
开启了 14G swap。
测试工具
使用 Redis-Benchmark,使用 Unix socket 连接,1024 个连接(默认 50),每个指令测试 1024000 次(默认 100000)。
1 | 测试 Redis |
测试结果
资源占用
Redis 测试时监控
Valkey 测试时监控
性能对比
rps | avg_latency_ms | min_latency_ms | p50_latency_ms | p95_latency_ms | p99_latency_ms | max_latency_ms | |||||||||||||||
Redis | ValKey | 对比 | Redis | ValKey | 对比 | Redis | ValKey | 对比 | Redis | ValKey | 对比 | Redis | ValKey | 对比 | Redis | ValKey | 对比 | Redis | ValKey | 对比 | |
PING_INLINE | 101026.05 | 105567.02 | 4.49% | 5.079 | 4.864 | -4.23% | 2.72 | 2.072 | -23.82% | 5.055 | 4.839 | -4.27% | 5.391 | 5.119 | -5.05% | 5.599 | 5.319 | -5.00% | 25.807 | 33.183 | 28.58% |
PING_MBULK | 101637.72 | 105894.52 | 4.19% | 5.043 | 4.844 | -3.95% | 2.272 | 2.224 | -2.11% | 5.031 | 4.823 | -4.13% | 5.367 | 5.127 | -4.47% | 5.583 | 5.335 | -4.44% | 11.175 | 21.439 | 91.85% |
SET | 100747.74 | 103257.04 | 2.49% | 5.089 | 4.972 | -2.30% | 3 | 2.12 | -29.33% | 5.079 | 4.935 | -2.84% | 5.415 | 5.263 | -2.81% | 5.591 | 5.455 | -2.43% | 12.631 | 25.727 | 103.68% |
GET | 101809.51 | 103906.65 | 2.06% | 5.035 | 4.939 | -1.91% | 1.96 | 2.848 | 45.31% | 5.023 | 4.903 | -2.39% | 5.375 | 5.215 | -2.98% | 5.599 | 5.375 | -4.00% | 11.783 | 25.503 | 116.44% |
INCR | 102073.37 | 103517.99 | 1.42% | 5.022 | 4.958 | -1.27% | 2.072 | 2.64 | 27.41% | 5.015 | 4.935 | -1.60% | 5.343 | 5.231 | -2.10% | 5.551 | 5.463 | -1.59% | 12.135 | 21.839 | 79.97% |
LPUSH | 100688.3 | 103612.26 | 2.90% | 5.092 | 4.953 | -2.73% | 2.8 | 2.656 | -5.14% | 5.079 | 4.919 | -3.15% | 5.415 | 5.223 | -3.55% | 5.599 | 5.407 | -3.43% | 12.855 | 25.999 | 102.25% |
RPUSH | 102708.12 | 104160.3 | 1.41% | 4.988 | 4.927 | -1.22% | 2.08 | 2.44 | 17.31% | 4.975 | 4.911 | -1.29% | 5.319 | 5.207 | -2.11% | 5.527 | 5.407 | -2.17% | 12.039 | 22.703 | 88.58% |
LPOP | 101890.55 | 104319.48 | 2.38% | 5.035 | 4.92 | -2.28% | 2.848 | 2.816 | -1.12% | 5.023 | 4.895 | -2.55% | 5.319 | 5.191 | -2.41% | 5.543 | 5.415 | -2.31% | 13.287 | 24.063 | 81.10% |
RPOP | 101105.84 | 104724.89 | 3.58% | 5.072 | 4.901 | -3.37% | 2.688 | 2.784 | 3.57% | 5.055 | 4.871 | -3.64% | 5.335 | 5.151 | -3.45% | 5.519 | 5.311 | -3.77% | 14.807 | 26.495 | 78.94% |
SADD | 101860.13 | 105556.12 | 3.63% | 5.032 | 4.862 | -3.38% | 2.408 | 2.736 | 13.62% | 5.023 | 4.831 | -3.82% | 5.335 | 5.111 | -4.20% | 5.527 | 5.399 | -2.32% | 11.895 | 24.687 | 107.54% |
HSET | 102297.7 | 105839.79 | 3.46% | 5.012 | 4.851 | -3.21% | 2.984 | 1.984 | -33.51% | 5.007 | 4.823 | -3.67% | 5.295 | 5.119 | -3.32% | 5.495 | 5.351 | -2.62% | 13.111 | 26.959 | 105.62% |
SPOP | 102862.88 | 105414.87 | 2.48% | 4.984 | 4.868 | -2.33% | 2.32 | 2.568 | 10.69% | 4.975 | 4.839 | -2.73% | 5.271 | 5.127 | -2.73% | 5.447 | 5.351 | -1.76% | 13.495 | 23.919 | 77.24% |
ZADD | 101728.59 | 105556.12 | 3.76% | 5.04 | 4.863 | -3.51% | 3.088 | 2.768 | -10.36% | 5.023 | 4.839 | -3.66% | 5.375 | 5.151 | -4.17% | 5.639 | 5.399 | -4.26% | 13.143 | 20.751 | 57.89% |
ZPOPMIN | 101335.98 | 105469.16 | 4.08% | 5.059 | 4.867 | -3.80% | 2.944 | 2.416 | -17.93% | 5.055 | 4.839 | -4.27% | 5.407 | 5.111 | -5.47% | 5.663 | 5.327 | -5.93% | 11.199 | 25.615 | 128.73% |
LPUSH (needed to benchmark LRANGE) | 100777.48 | 104139.12 | 3.34% | 5.088 | 4.928 | -3.14% | 2.528 | 2.64 | 4.43% | 5.071 | 4.903 | -3.31% | 5.399 | 5.215 | -3.41% | 5.599 | 5.431 | -3.00% | 13.487 | 25.615 | 89.92% |
LRANGE_100 (first 100 elements) | 57206.71 | 58601.35 | 2.44% | 8.958 | 8.746 | -2.37% | 4.816 | 4.896 | 1.66% | 8.911 | 8.735 | -1.98% | 9.471 | 9.839 | 3.89% | 9.783 | 10.319 | 5.48% | 25.615 | 35.775 | 39.66% |
LRANGE_300 (first 300 elements) | 22433.02 | 22429.58 | -0.02% | 22.825 | 22.825 | 0.00% | 5.08 | 4.912 | -3.31% | 22.831 | 22.831 | 0.00% | 26.367 | 27.391 | 3.88% | 27.471 | 28.271 | 2.91% | 58.687 | 63.199 | 7.69% |
LRANGE_500 (first 500 elements) | 14708.84 | 14761 | 0.35% | 34.813 | 34.682 | -0.38% | 4.928 | 4.976 | 0.97% | 34.815 | 34.687 | -0.37% | 39.711 | 42.143 | 6.12% | 41.439 | 43.775 | 5.64% | 98.111 | 98.879 | 0.78% |
LRANGE_600 (first 600 elements) | 12634.49 | 12635.27 | 0.01% | 40.527 | 40.517 | -0.02% | 4.944 | 4.952 | 0.16% | 40.511 | 40.511 | 0.00% | 42.719 | 49.439 | 15.73% | 44.383 | 52.383 | 18.02% | 110.911 | 110.335 | -0.52% |
MSET (10 keys) | 100727.91 | 103142.62 | 2.40% | 5.1 | 4.985 | -2.25% | 2.552 | 2.6 | 1.88% | 5.063 | 4.927 | -2.69% | 5.391 | 5.287 | -1.93% | 5.655 | 5.991 | 5.94% | 17.599 | 26.623 | 51.28% |
XADD | 100926.48 | 103727.72 | 2.78% | 5.083 | 4.95 | -2.62% | 2.424 | 2.816 | 16.17% | 5.071 | 4.911 | -3.16% | 5.391 | 5.263 | -2.37% | 5.575 | 5.775 | 3.59% | 13.615 | 26.351 | 93.54% |
结论
对比下来,差距不大,针对不同场景也各有优劣,最大延迟上面 Valkey 表现普遍不如 Redis,其他指标上 Valkey 略胜一筹,说明 Valkey 表现波动比
Reids 要大,这点从硬件资源监控也能发现 Valkey 的 CPU 使用上不如 Redis 平稳。
针对 redis-Benchmark 的一些局限性,后面计划再用 resp-benchmark
测试看看会不会有差异。