01测试-redis-benchmark压力测试
redis自带有redis-benchmark工具做压力测试,经常用来测试新版本,新特性对基准测试性能的影响。参数场景变化下的性能状况。
主要参数:
-h <hostname> 服务器地址 (default 127.0.0.1)
-p <port> 端口 (default 6379)
-s <socket> socket (overrides host and port)
-a <password> 密码
-c <clients> 并行连接数(default 50)
-n <requests> 总请求数 (default 100000)
-d <size> SET/GET请求value大小,单位:bytes (default 3)
--dbnum <db> SELECT 指定库 (default 0)
-k <boolean> 是否采用keep alive模式,0是,1为reconnect (default 1)
-r <keyspacelen> 为sadd集合操作SET/GET/INCR随机产生key,随机产生value。
-P <numreq> pipeline请求数. Default 1 (no pipeline).
-e 输出错误信息,每秒显示不超过1个错误。
-q Quiet. 仅仅查看每秒的查询数。
--csv 输出为CSV格式。
-l 循环次数。
-t <tests> 指定测试命令。
-I 打开空连接,并等待。
Examples:
1.进行20个并发请求,10万请求量,测试set、get、incr、lpush,rpush,lpop、rpop、sadd、hset、
spop、range前100个元素、range前300个元素、range前500个元素、range前600个元素、mset。比较全面的测试
$ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20
2.测试set随机数的性能。
$ redis-benchmark -t set -n 1000000 -r 100000000
3.测试ping,set,get 10万请求性能,csv输出:
$ redis-benchmark -t ping,set,get -n 100000 --csv
4.测试指定命令性能:
$ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0
5.测试list随机10000个元素写入lpush:
$ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__
测试记录:
本次测试版本,配置等。
[root@rcsy ~]# redis-cli -a mysql info | grep version
redis_version:4.0.14
gcc_version:4.8.5
内存2G,2颗核心,SSD:30G。
[root@rcsy redis-4.0.14]# redis-benchmark -n 100000 -c 20 -a mysql
====== PING_INLINE ======
100000 requests completed in 1.99 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.94% <= 1 milliseconds
99.96% <= 2 milliseconds
100.00% <= 3 milliseconds
50251.26 requests per second
====== PING_BULK ======
100000 requests completed in 2.13 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.92% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 2 milliseconds
46970.41 requests per second
====== SET ======
100000 requests completed in 2.02 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.94% <= 1 milliseconds
99.98% <= 2 milliseconds
99.99% <= 3 milliseconds
100.00% <= 3 milliseconds
49431.54 requests per second
====== GET ======
100000 requests completed in 2.12 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.91% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 2 milliseconds
47236.65 requests per second
====== INCR ======
100000 requests completed in 2.09 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.96% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 2 milliseconds
47801.15 requests per second
====== LPUSH ======
100000 requests completed in 2.06 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.87% <= 1 milliseconds
99.96% <= 2 milliseconds
99.99% <= 3 milliseconds
100.00% <= 3 milliseconds
48567.27 requests per second
====== RPUSH ======
100000 requests completed in 2.05 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.93% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 2 milliseconds
48685.49 requests per second
====== LPOP ======
100000 requests completed in 2.09 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.95% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 2 milliseconds
47915.67 requests per second
====== RPOP ======
100000 requests completed in 2.11 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.93% <= 1 milliseconds
99.98% <= 2 milliseconds
99.99% <= 4 milliseconds
100.00% <= 4 milliseconds
47438.33 requests per second
====== SADD ======
100000 requests completed in 2.14 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.90% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 2 milliseconds
46620.05 requests per second
====== HSET ======
100000 requests completed in 2.08 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.91% <= 1 milliseconds
99.99% <= 2 milliseconds
100.00% <= 2 milliseconds
47984.64 requests per second
====== SPOP ======
100000 requests completed in 2.17 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.92% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 3 milliseconds
100.00% <= 3 milliseconds
46146.75 requests per second
====== LPUSH (needed to benchmark LRANGE) ======
100000 requests completed in 2.12 seconds
20 parallel clients
3 bytes payload
keep alive: 1
99.93% <= 1 milliseconds
99.96% <= 2 milliseconds
99.97% <= 3 milliseconds
99.99% <= 4 milliseconds
100.00% <= 4 milliseconds
47281.32 requests per second
====== LRANGE_100 (first 100 elements) ======
100000 requests completed in 6.34 seconds
20 parallel clients
3 bytes payload
keep alive: 1
61.85% <= 1 milliseconds
99.77% <= 2 milliseconds
99.98% <= 3 milliseconds
100.00% <= 3 milliseconds
15782.83 requests per second
====== LRANGE_300 (first 300 elements) ======
100000 requests completed in 15.55 seconds
20 parallel clients
3 bytes payload
keep alive: 1
1.24% <= 1 milliseconds
39.79% <= 2 milliseconds
92.01% <= 3 milliseconds
98.24% <= 4 milliseconds
99.87% <= 5 milliseconds
99.95% <= 6 milliseconds
99.96% <= 7 milliseconds
99.97% <= 8 milliseconds
99.98% <= 9 milliseconds
99.98% <= 10 milliseconds
99.98% <= 11 milliseconds
99.99% <= 12 milliseconds
99.99% <= 15 milliseconds
99.99% <= 16 milliseconds
99.99% <= 24 milliseconds
100.00% <= 25 milliseconds
100.00% <= 26 milliseconds
6431.28 requests per second
====== LRANGE_500 (first 450 elements) ======
100000 requests completed in 22.25 seconds
20 parallel clients
3 bytes payload
keep alive: 1
0.76% <= 1 milliseconds
15.27% <= 2 milliseconds
50.68% <= 3 milliseconds
83.07% <= 4 milliseconds
93.83% <= 5 milliseconds
97.42% <= 6 milliseconds
99.28% <= 7 milliseconds
99.69% <= 8 milliseconds
99.82% <= 9 milliseconds
99.88% <= 10 milliseconds
99.91% <= 11 milliseconds
99.92% <= 12 milliseconds
99.93% <= 13 milliseconds
99.94% <= 14 milliseconds
99.94% <= 15 milliseconds
99.95% <= 16 milliseconds
99.98% <= 17 milliseconds
99.99% <= 18 milliseconds
99.99% <= 19 milliseconds
99.99% <= 30 milliseconds
99.99% <= 31 milliseconds
100.00% <= 32 milliseconds
100.00% <= 32 milliseconds
4494.38 requests per second
====== LRANGE_600 (first 600 elements) ======
100000 requests completed in 29.40 seconds
20 parallel clients
3 bytes payload
keep alive: 1
0.04% <= 1 milliseconds
1.65% <= 2 milliseconds
13.74% <= 3 milliseconds
48.50% <= 4 milliseconds
78.79% <= 5 milliseconds
92.05% <= 6 milliseconds
95.91% <= 7 milliseconds
98.48% <= 8 milliseconds
99.74% <= 9 milliseconds
99.86% <= 10 milliseconds
99.89% <= 11 milliseconds
99.90% <= 12 milliseconds
99.91% <= 13 milliseconds
99.92% <= 14 milliseconds
99.93% <= 15 milliseconds
99.94% <= 16 milliseconds
99.96% <= 17 milliseconds
99.97% <= 18 milliseconds
99.98% <= 19 milliseconds
99.98% <= 20 milliseconds
100.00% <= 21 milliseconds
100.00% <= 21 milliseconds
3401.82 requests per second
====== MSET (10 keys) ======
100000 requests completed in 3.61 seconds
20 parallel clients
3 bytes payload
keep alive: 1
98.40% <= 1 milliseconds
99.93% <= 2 milliseconds
100.00% <= 2 milliseconds
27670.17 requests per second
基本上ping、set、get、lpush、lpop、spop等都达到4-5万多rps,但lrange前100、300、500等就比较慢了,
随着范围越大,月底。从16000--6400---4500--3400,可以看到100-300下降一半多。
压力情况:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24657 root 20 0 16908 5788 968 S 99.3 0.3 0:27.31 redis-benchmark
24624 root 20 0 149408 10744 1288 R 95.4 0.6 2:11.72 redis-server
可以看到,CPU基本被占满。 按照正常来讲,至少set,get至少上8万。
[root@rcsy ~]# redis-benchmark -t set -n 1000000 -r 100000000
====== SET ======
1000000 requests completed in 21.45 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.03% <= 1 milliseconds
99.96% <= 2 milliseconds
99.98% <= 3 milliseconds
99.98% <= 4 milliseconds
99.99% <= 5 milliseconds
99.99% <= 8 milliseconds
100.00% <= 9 milliseconds
100.00% <= 10 milliseconds
100.00% <= 12 milliseconds
100.00% <= 12 milliseconds
46620.05 requests per second
[root@rcsy ~]# redis-benchmark -t ping,set,get -n 100000 --csv
"PING_INLINE","48899.75"
"PING_BULK","45351.48"
"SET","44943.82"
"GET","45351.48"
[root@rcsy ~]# redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0
====== eval return redis.call("ping") 0 ======
10000 requests completed in 0.22 seconds
50 parallel clients
3 bytes payload
keep alive: 1
98.29% <= 1 milliseconds
99.51% <= 3 milliseconds
99.74% <= 4 milliseconds
99.96% <= 5 milliseconds
100.00% <= 5 milliseconds
46082.95 requests per second
[root@rcsy ~]# redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__
====== lpush mylist __rand_int__ ======
10000 requests completed in 0.22 seconds
50 parallel clients
3 bytes payload
keep alive: 1
98.80% <= 1 milliseconds
99.51% <= 2 milliseconds
99.80% <= 3 milliseconds
100.00% <= 3 milliseconds
46082.95 requests per second
标签:20,100.00%,benchmark,redis,alive,bytes,100000,测试,requests From: https://www.cnblogs.com/rcsy/p/18295072