Redis有自己的压测工具redis-benchmark
[root@dblight src]# ./redis-benchmark -h
Invalid option “-h” or option argument missing
Usage: redis-benchmark [-h
-h
-p
-s
-a
-c
-n
-d
–dbnum
-k
-r
Using this option the benchmark will expand the string rand_int
inside an argument with a 12 digits number in the specified range
from 0 to keyspacelen-1. The substitution changes every time a command
is executed. Default tests use this to hit random keys in the
specified range.
-P
-e If server replies with errors, show them on stdout.
(no more than 1 error per second is displayed)
-q Quiet. Just show query/sec values
–csv Output in CSV format
-l Loop. Run the tests forever
-t
names are the same as the ones produced as output.
-I Idle mode. Just open N idle connections and wait.
Examples:
Run the benchmark with the default configuration against 127.0.0.1:6379:
$ redis-benchmark
Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:
$ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20
Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:
$ redis-benchmark -t set -n 1000000 -r 100000000
Benchmark 127.0.0.1:6379 for a few commands producing CSV output:
$ redis-benchmark -t ping,set,get -n 100000 --csv
Benchmark a specific command line:
$ redis-benchmark -r 10000 -n 10000 eval ‘return redis.call(“ping”)’ 0
Fill a list with 10000 random elements:
$ redis-benchmark -r 10000 -n 10000 lpush mylist rand_int
如果是在本机,可以直接在src目录执行。./redis-benchmark 即可看到输入结果,我们只需要看比较核心的指标,在100000个请求,100个并发的情况下进行压测,并将结果输入成新文件方便查询:
[root@dblight src]# ./redis-benchmark -h 127.0.0.1 -c 100 -n 100000 > benchmark_result.txt
对生成结果进行过滤查询:
[root@dblight src]# cat benchmark_result.txt | grep -E ‘======|requests|per’
====== PING_INLINE ======
100000 requests completed in 2.19 seconds
45620.44 requests per second
====== PING_BULK ======
100000 requests completed in 2.26 seconds
44189.13 requests per second
====== SET ======
100000 requests completed in 2.35 seconds
42480.88 requests per second
====== GET ======
100000 requests completed in 2.33 seconds
42992.26 requests per second
====== INCR ======
100000 requests completed in 2.94 seconds
34048.35 requests per second
====== LPUSH ======
100000 requests completed in 3.03 seconds
32981.53 requests per second
====== RPUSH ======
100000 requests completed in 2.72 seconds
36724.20 requests per second
====== LPOP ======
100000 requests completed in 2.41 seconds
41459.37 requests per second
====== RPOP ======
100000 requests completed in 2.87 seconds
34831.07 requests per second
====== SADD ======
100000 requests completed in 3.72 seconds
26845.64 requests per second
====== HSET ======
100000 requests completed in 3.09 seconds
32341.53 requests per second
====== SPOP ======
100000 requests completed in 3.55 seconds
28161.08 requests per second
====== LPUSH (needed to benchmark LRANGE) ======
100000 requests completed in 2.74 seconds
36429.88 requests per second
====== LRANGE_100 (first 100 elements) ======
100000 requests completed in 4.32 seconds
23137.44 requests per second
====== LRANGE_300 (first 300 elements) ======
100000 requests completed in 8.30 seconds
12048.19 requests per second
====== LRANGE_500 (first 450 elements) ======
100000 requests completed in 9.63 seconds
10379.90 requests per second
====== LRANGE_600 (first 600 elements) ======
100000 requests completed in 10.86 seconds
9204.71 requests per second
====== MSET (10 keys) ======
100000 requests completed in 2.53 seconds
39588.28 requests per second




