暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

redis压测简述

原创 黄堋 2020-05-26
2380

Redis有自己的压测工具redis-benchmark
[root@dblight src]# ./redis-benchmark -h
Invalid option “-h” or option argument missing

Usage: redis-benchmark [-h ] [-p ] [-c ] [-n ] [-k ]

-h Server hostname (default 127.0.0.1)
-p Server port (default 6379)
-s Server socket (overrides host and port)
-a Password for Redis Auth
-c Number of parallel connections (default 50)
-n Total number of requests (default 100000)
-d Data size of SET/GET value in bytes (default 3)
–dbnum SELECT the specified db number (default 0)
-k 1=keep alive 0=reconnect (default 1)
-r Use random keys for SET/GET/INCR, random values for SADD
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 Pipeline requests. Default 1 (no pipeline).
-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 Only run the comma separated list of tests. The test
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

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论