Introduction
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.
For some cases, we need to know the performance benchmark of redis sentinel and redis cluster. In this guide, will introduce two tools can be used to do redis performance test.
Tools
redis_benchmark is the tool included in redis, is the utility to check the performance of Redis by running n commands simultaneously.
memtier_benchmark is developed by Redis Labs for load generation and benchmarking NoSQL key-value databases. https://github.com/RedisLabs/memtier_benchmark
redis_benchmark
redis_benchmark is included in redis, so when after install redis, redis_benchmark can be used.
Common Usage
the following options are the common used ones:
- -h Server hostname (default 127.0.0.1)
- -p Server port (default 6379)
- -c Number of parallel connections (default 50)
- -n Total number of requests (default 100000)
- -d Data size of SET/GET value in bytes (default 2)
- -P Pipeline requests. Default 1 (no pipeline)
demo:
redis-benchmark -h {ip} -p {port} -t {command} -c {client number} -n {request number} -r {random key} -d {datasize}
redis-benchmark -h {ip} -p {port} -c {client number} -n {request number} -r {random key} -e -l set __rand_int__ __rand_int__
redis-benchmark -h {ip} -p {port} -c {client number} -n {request number} -r {random key} mset __rand_int__ __rand_int__ __rand_int__ __rand_int__ __rand_int__ __rand_int__ __rand_int__ __rand_int__
Output
return the latency and its qps.

memtier_benchmark
Install memtier_benchmark on ubuntu
#install the dependency
apt-get install build-essential autoconf automake libpcre3-dev libevent-dev pkg-config zlib1g-dev libssl-dev
#clone the code
git clone https://github.com/RedisLabs/memtier_benchmark.git
#run autoreconf to generate the default scripts
cd memtier_benchmark
autoreconf -ivf
#generate and run the application
./configure
make
#check install success
./memtier_benchmark --version
memtier_benchmark 1.3.0
Copyright (C) 2011-2020 Redis Labs Ltd.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
Common Usage
the following options are the common used ones:
- -s, –server=ADDR Server address (default: localhost)
- -p, –port=PORT Server port (default: 6379)
- -n, –requests=NUMBER Number of total requests per client (default: 10000)
- -c, –clients=NUMBER Number of clients per thread (default: 50)
- -t, –threads=NUMBER Number of threads (default: 4)
- –test-time=SECS Number of seconds to run the test
- –command=COMMAND Specify a command to send in quotes.
- -d –data-size=SIZE Object data size (default: 32)
demo:
./memtier_benchmark -s {server} -p {port} --test-time=90 --command "set __key__ __data__" -c 20 -d 32 --key-minimum 1 --key-maximum 1000000
./memtier_benchmark -s {server} -p {port} --test-time=90 --command "get __key__" -c 20 -d 32 --key-minimum 1 --key-maximum 1000000
./memtier_benchmark -s {server} -p {port} --test-time=90 --command "set __key__ __data__" -c 15 --data-size-range 32-1024 --key-minimum 1 --key-maximum 1000000
./memtier_benchmark -s {server} -p {port} --test-time=90 --ratio=1:1 -c 20 --data-size-range 32-1024 --key-minimum 1 --key-maximum 1000000
./memtier_benchmark -s {server} -p {port} -c 20 --threads 10 --key-minimum 1 --key-maximum 400000 -n 20000 --key-prefix listdata --random-data --data-size 4096 --distinct-client-seed --print-percentiles 50,90,99,100 --hide-histogram --command "sadd __key__ __data__" --command-ratio=1 --command "sismember __key__ __data__" --command-ratio=1
some other options:
- –distinct-client-seed: if want to random the seed for each client, can add such option
- –print-percentiles: Specify which percentiles info to print on the results table, –print-percentiles 50,90,99,100
- –hide-histogram: don’t print detailed latency histogram
- –json-out-file: output to json format, will help u to analysis
- –random-data –data-size 512: can random the __data__
Output
return the qps & the specified latency

User Scenarios
Do redis performance test
./memtier_benchmark -s {server} -p {port} -c 20 --threads 10 --key-minimum 1 --key-maximum 400000 -n 20000 --key-prefix listdata --random-data --data-size 4096 --distinct-client-seed --print-percentiles 50,90,99,100 --hide-histogram --command "sadd __key__ __data__" --command-ratio=1 --command "sismember __key__ __data__" --command-ratio=9
Write data to redis
redis-benchmark -h {server} -p {port} -c 100 -d 128 -n 10000000 -r 10000000 -e -l set __rand_int__ __rand_int__
Do long stability test
nohup redis-benchmark -h {server} -p {port} -c 100 -d 128 -n 10000000 -r 10000000 -e -l set __rand_int__ __rand_int__ >> bench.log 2>&1 &
make bigkey
redis-benchmark -h {server} -p {port} -c 100 -d 128 -n 10000000 -r 10000000 -e -l lpush key1 __rand_int__