NOTE

1.11 Redis Benchmarking

Benchmark Lua scripts and pipelines with redis-benchmark, plus practical benchmarking notes.

Redis / CacheCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Benchmark a Lua Script

  1. Load Lua with redis-cli
redis-cli -h 127.0.0.1 -p 6379 -a "xxx" -x script load < test.lua
  1. 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
  1. 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

  1. First benchmark Redis locally so network bottlenecks (bandwidth + latency) can be ignored.
  2. redis-benchmark is also single-threaded. If CPU reaches 100%, multiple redis-benchmark processes can be started for the benchmark and their QPS values added together.
  3. If there are other problems, capture packets with tcpdump and analyze them with Wireshark.

3. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub