分享更有价值
被信任是一种快乐

nosql redis数据库压力测试基准工具redis-benchmark怎么用

文章页正文上

这篇文章将为大家详细讲解有关nosql redis数据库压力测试基准工具redis-benchmark怎么用,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1,查看基准测试工具的用法
[root@langfang src]# pwd
/redis_dir/redis-4.0.9/src
[root@langfang src]# ./redis-benchmark -help
Invalid option “-help” or option argument missing

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

-h Server hostname (default 127.0.0.1) -h 连接REDIS服务器IP,默认为127.0.0.1
-p Server port (default 6379) -P REDIS服务器端口 ,默认为6379
-s Server socket (overrides host and port) -S 服务器套接字(覆盖主机和端口)
-a Password for Redis Auth –A REDIS AUTH的认证密码
-c Number of parallel connections (default 50) –c 表示并发连接数量,默认50个
-n Total number of requests (default 100000) —n 请求的总数量,默认为100000,即10万
-d Data size of SET/GET value in bytes (default 3) –D 表示SET GET的大小,默认大小为3
–dbnum SELECT the specified db number (default 0) –dbnum 指定连接哪个数据库,默认为0号数据库
-k 1=keep alive 0=reconnect (default 1) -k 布尔类型,1为保持连接,默认值;0为重连
-r Use random keys for SET/GET/INCR, random values for SADD –r 为SET GET INCR操作使用随机的键,为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). –P 与管道技术有关,请求的次数,默认为1,即禁用管道技术,假如服务器报错,显示报错信息
-e If server replies with errors, show them on stdout.
(no more than 1 error per second is displayed) –仅仅每秒显示1个报错
-q Quiet. Just show query/sec values -Q 安静,仅仅显示 每秒 查询值
–csv Output in CSV format –CSV 以CSV格式输出
-l Loop. Run the tests forever -L 一直压测,不停止
-t Only run the comma separated list of tests. The test -T -L 运行以 逗 号分隔的测试列表,指定具体的压力测试场景,比如是set or mget or get and so on
names are the same as the ones produced as output.
-I Idle mode. Just open N idle connections and wait. –L 空闲模式,只是打开N个空闲连接然后等待

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__

On user specified command line免费主机域名s __rand_int__ is replaced with a random integer
with a range of values selected by the -r option.
[root@langfang src]#

2,redis-benchmark默认压力测试
–压力测试结论包括 压力测试消耗时间及每秒最大处理的请求数以及各种的压力测试场景的不同子节
[root@langfang src]# ./redis-benchmark
====== PING_INLINE ====== —概述的名称
100000 requests completed in 1.51 seconds –概要结论,消耗 1.51秒 完成 10万次请求
50 parallel clients
3 bytes payload
keep alive: 1

96.26% 99.96% 100.00% 66181.34 requests per second –每秒完成 6.6万左右请求

====== PING_BULK ======
100000 requests completed in 1.70 seconds
50 parallel clients
3 bytes payload
keep alive: 1

93.00% 99.98% 100.00% 58788.95 requests per second

====== SET ======
100000 requests completed in 1.69 seconds
50 parallel clients
3 bytes payload
keep alive: 1

92.51% 99.95% 100.00% 59241.71 requests per second

====== GET ======
100000 requests completed in 1.53 seconds
50 parallel clients
3 bytes payload
keep alive: 1

96.22% 99.97% 100.00% 65402.22 requests per second

====== INCR ======
100000 requests completed in 1.55 seconds
50 parallel clients
3 bytes payload
keep alive: 1

95.60% 100.00% 100.00% 64683.05 requests per second

====== LPUSH ======
100000 requests completed in 1.52 seconds
50 parallel clients
3 bytes payload
keep alive: 1

94.17% 99.99% 100.00% 65573.77 requests per second

====== RPUSH ======
100000 requests completed in 1.57 seconds
50 parallel clients
3 bytes payload
keep alive: 1

94.06% 99.97% 100.00% 63734.86 requests per second

====== LPOP ======
100000 requests completed in 1.51 seconds
50 parallel clients
3 bytes payload
keep alive: 1

94.25% 99.98% 100.00% 66269.05 requests per second

====== RPOP ======
100000 requests completed in 1.52 seconds
50 parallel clients
3 bytes payload
keep alive: 1

95.01% 99.95% 100.00% 65919.58 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
100000 requests completed in 1.50 seconds
50 parallel clients

====== LRANGE_500 (first 450 elements) ======
100000 requests completed in 10.29 seconds
50 parallel clients
3 bytes payload
keep alive: 1

3.16% 22.80% 46.08% 65.75% 81.96% 94.78%

====== MSET (10 keys) ======
100000 requests completed in 2.06 seconds
50 parallel clients
3 bytes payload
keep alive: 1

57.05%免费主机域名 98.41% 99.98% 100.00% 48567.27 requests per second

[root@langfang src]#

3,还是各种压测场景,不过是20个并发,10万次请求,连接指定REDIS服务器
[root@langfang src]# ./redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 20
====== PING_INLINE ======
100000 requests completed in 1.63 seconds
20 parallel clients
3 bytes payload
keep alive: 1

99.69% 100.00% 61312.08 requests per second

====== PING_BULK ======
100000 requests completed in 1.67 seconds
20 parallel clients
3 bytes payload
keep alive: 1

4,指定测试场景比如 GET AND SET 以及随机键的数量以及请求个数
[root@langfang src]# ./redis-benchmark -t set,get -n 100000 -r 1000
====== SET ======
100000 requests completed in 1.60 seconds
50 parallel clients
3 bytes payload
keep alive: 1

94.68% 99.93% 100.00% 62656.64 requests per second

====== GET ======
100000 requests completed in 1.68 seconds
50 parallel clients
3 bytes payload
keep alive: 1

93.91% 99.93% 100.00% 59488.40 requests per second

5,csv格式输出
[root@langfang src]# ./redis-benchmark -t ping,get,set -n 1000 –csv
“PING_INLINE”,”52631.58″
“PING_BULK”,”55555.56″
“SET”,”52631.58″
“GET”,”52631.58″

6,运行特定的命令行
[root@langfang src]# ./redis-benchmark -r 1000 -n 100000 eval ‘return redis.call(“ping”)’
====== eval return redis.call(“ping”) ======
100000 requests completed in 1.56 seconds
50 parallel clients
3 bytes payload
keep alive: 1

95.66% 99.93% 100.00% 63979.53 requests per second

7, Fill a list with 10000 random elements 以随机指定的范围元素填充list
[root@langfang src]# ./redis-benchmark -r 10000 -n 1000 lpush mylist _rand_init__
====== lpush mylist _rand_init__ ======
1000 requests completed in 0.02 seconds
50 parallel clients
3 bytes payload
keep alive: 1

87.20% 99.50% 100.00% 47619.05 requests per second

[root@langfang src]# ./redis-benchmark -r 10000 -n 1000 set mylist _rand_init__
====== set mylist _rand_init__ ======
1000 requests completed in 0.02 seconds
50 parallel clients
3 bytes payload
keep alive: 1

86.40% 100.00% 47619.05 requests per second

8,静默方式压力测试
[root@langfang src]# ./redis-benchmark -t set,get -n 100000 -r 1000
====== SET ======
100000 requests completed in 1.58 seconds
50 parallel clients
3 bytes payload
keep alive: 1

94.99% 99.96% 100.00% 63211.12 requests per second

====== GET ======
100000 requests completed in 1.60 seconds
50 parallel clients
3 bytes payload
keep alive: 1

95.21% 99.99% 100.00% 62617.41 requests per second

–可见静默方式只显示每次处理的请求数以及压力测试场景
[root@langfang src]# ./redis-benchmark -t set,get -n 100000 -r 1000 -q
SET: 63091.48 requests per second
GET: 64724.92 requests per second

9,redis-cli可以直接附上操作命令
[root@langfang src]# ./redis-cli flushall
OK
[root@langfang src]# ./redis-cli dbsize
(integer) 0
[root@langfang src]#

10,–r表示产生的随机键的数量,数量大可以模拟 键不命中情况
[root@langfang src]# ./redis-cli dbsize
(integer) 0
[root@langfang src]# ./redis-benchmark -t set -r 8888 -n 100000
====== SET ======
100000 requests completed in 1.61 seconds
50 parallel clients
3 bytes payload
keep alive: 1

94.16% 99.93% 99.95% 100.00% 62305.30 requests per second

[root@langfang src]# ./redis-cli dbsize
(integer) 8888
[root@langfang src]#

11,默认情况是处理1个请求然后顺序接着处理下1个请求,但可以通过-P 管道技术,并发处理多个请求,下述效果非常明显,成9倍左右的差异
(同时处理多条命令需要PIPELINE管道技术)

[root@langfang src]# ./redis-benchmark -t get,set -n 100000 -q
SET: 64516.13 requests per second
GET: 64516.13 requests per second

[root@langfang src]# ./redis-benchmark -t get,set -n 100000 -P 16 -q
SET: 452488.69 requests per second
GET: 529100.56 requests per second

关于“nosql redis数据库压力测试基准工具redis-benchmark怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

相关推荐: Oracle Rac常用命令有哪些

这篇文章主要介绍“免费主机域名Oracle Rac常用命令有哪些”,免费主机域名在日常操作中,相信很多人在Oracle Rac常用命令有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Oracle Rac常用命令有哪些”的疑惑…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册