Redis 性能测试
用 redis-benchmark 压测吞吐与延迟。
Key Pointsredis-benchmark 是官方压测工具,能快速看出单实例 QPS 上限。
常用压测
Shell
redis-benchmark -q -n 100000 # 10 万次请求,精简输出
redis-benchmark -t set,get -n 100000 -c 50 # 50 并发跑 SET/GET
redis-benchmark -n 100000 -d 256 # value 256 字节Output
SET: 110000.00 requests per second
GET: 120000.00 requests per secondQPS depends on value size, concurrency and whether AOF is on. Benchmark close to real traffic (similar value sizes, command mix) — don't trust only the default SET/GET numbers.
常用压测
Shell
redis-benchmark -q -n 100000 # 10 万次请求,精简输出
redis-benchmark -t set,get -n 100000 -c 50 # 50 并发跑 SET/GET
redis-benchmark -n 100000 -d 256 # value 256 字节Output
SET: 110000.00 requests per second
GET: 120000.00 requests per secondQPS 受 value 大小、并发、是否开启 AOF 影响。压测要贴近真实场景(相近的 value 尺寸、相近的命令组合),别只信默认 SET/GET 的漂亮数字。