NOTE
1.11 Redis Benchmarking
Benchmark Lua scripts and pipelines with redis-benchmark, plus practical benchmarking notes.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Benchmark a Lua Script
- Load Lua with redis-cli
redis-cli -h 127.0.0.1 -p 6379 -a "xxx" -x script load < test.lua
- Benchmark Lua with redis-benchmark
# 1 represents the number of keys
redis-benchmark -h 127.0.0.1 -p 6379 -a "xxx" -c 1000 -n 1000000 evalsha d72ab028ab5ff319cf0979291745f98c099cecb2 1 test 10
- Benchmark a pipeline with redis-benchmark
redis-benchmark -h 127.0.0.1 -p 6379 -a "xxx" -c 1000 -n 1000000 -P 5 evalsha d72ab028ab5ff319cf0979291745f98c099cecb2 1 test 10
This command sends evalsha d72ab028ab5ff319cf0979291745f98c099cecb2 1 test 10 in batches of 5 commands. The final QPS should be divided by 5.
2. Benchmarking Notes
- First benchmark Redis locally so network bottlenecks (bandwidth + latency) can be ignored.
redis-benchmarkis also single-threaded. If CPU reaches 100%, multipleredis-benchmarkprocesses can be started for the benchmark and their QPS values added together.- If there are other problems, capture packets with tcpdump and analyze them with Wireshark.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub