【提升自己系列】,Redis性能测试还能这样做

网友投稿 249 2022-11-19

【提升自己系列】,Redis性能测试还能这样做

01、服务器环境


参数



linux指令





系统



cat /etc/redhat-release



CentOS Linux release 7.8.2003 (Core)



内存



free -h



total:3.7G available:3.0G



CPU数量



cat /proc/cpuinfo



cpu cores       :2



HZ



cat /proc/cpuinfo |grep MHz|uniq



cpu MHz         : 2100.000


Redis之redis-benchmark

redis 提供了 redis-benchmark 工具便于我们做性能测试,可以使用 redis-benchmark- h 查看参数。


命令



描述



默认值



-h <hostname>



指定服务器主机名



127.0.0.1



-p <port>



指定服务器端口



6379



-s <socket>



指定服务器 socket



-a <password>



Redis 认证密码



-c <clients>



指定并发连接数



50



-n <requests>



指定请求数



10000



-d <size>



以字节(Byte)的形式指定 SET/GET 值的数据大小



3



--dbnum <db>



选择 Redis 数据库编号



0



--threads <num>



启用多线程模式



redis6以上才有



-k <boolean>



是否保持连接 1=keep alive 0=reconnect



1



-r <keyspacelen>



SET/GET/INCR 使用随机 KEY ,SADD 使用随机值



-P <numreq>



默认情况下,Redis 客户端一次请求只发起一个命令。通过 -P 参数,可以设置使用 pipelining功能,一次发起指定个请求,从而提升 QPS



1



-e



如果 Redis Server 返回错误,是否将错误打印出来。默认情况下不打印,通过该参数开启



-q



强制退出 redis。仅显示 query/sec 值



--csv



以 CSV 格式输出



-l (L)



生成循环,永久执行测试



-t <tests>



指定需要测试的 Redis 命令,多个命令通过逗号分隔。想测试 SET/GET 命令,则可以 -t SET,GET 来指定



-I (i)



Idle 模式。仅打开 N 个 idle 连接并等待。


01、Docker Redis测试

单并发测试

测试命令:

​​./redis-benchmark -c 1 -n 20000 -d 30720 -t set,get​​

测试结果每秒是 8000+的QPS

多并发测试

​​====== SET ======​​

20000 requests completed in 1.06 seconds 10 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no18903.59 requests per second

====== GET ====== 20000 requests completed in 1.30 seconds 10 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no15360.98 requests per second

测试 -P 命令

====== SET ====== 20007 requests completed in 0.47 seconds 50 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no42933.48 requests per second

====== GET ====== 20002 requests completed in 0.44 seconds 50 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no45253.39 requests per second

02、redis6 安装版测试

单并发测试

​​====== SET ======​​

200000 requests completed in 20.20 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no9900.01 requests per second

====== GET ====== 200000 requests completed in 20.01 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no9995.50 requests per second

多并发测试

====== SET ====== 200000 requests completed in 3.00 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no66622.25 requests per second

====== GET ====== 200000 requests completed in 3.02 seconds 10 parallel clients 3 bytes payload keep alive:1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no66137.57 requests per second

03、-P 测试

单并发测试

​​====== SET ======​​

200000 requests completed in 2.20 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no90991.81 requests per second

====== GET ====== 200000 requests completed in 2.15 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no92980.01 requests per second

多并发测试

​​====== SET ======​​

200010 requests completed in 0.42 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no480793.25 requests per second

====== GET ====== 200000 requests completed in 0.34 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no586510.25 requests per second

02、换服务器测试


参数



linux指令





系统



cat /etc/redhat-release



CentOS Linux release 7.7.1908 (Core)



内存



free -h



total:3.6G ,available:782M



CPU数量



cat /proc/cpuinfo



cpu cores       : 1



HZ



cat /proc/cpuinfo |grep MHz|uniq



cpu MHz         : 2500.002


01、Docker Redis

单并发测试

​​====== SET ======​​

20000 requests completed in 1.22 seconds 1 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no16420.36 requests per second

​​====== GET ======​​

20000 requests completed in 1.42 seconds 1 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no14094.43 requests per second

多并发测试

====== SET ====== 20000 requests completed in 0.66 seconds 10 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no30395.14 requests per second

====== GET ====== 20000 requests completed in 0.81 seconds 10 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no24721.88 requests per second

02、-P 测试

单并发测试

====== SET ====== 20000 requests completed in 0.59 seconds 1 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no33726.81 requests per second

====== GET ====== 20000 requests completed in 0.50 seconds 1 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no39682.54 requests per second

多并发测试

​​====== SET ======​​

20008 requests completed in 0.31 seconds 10 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no64750.81 requests per second

====== GET ====== 20017 requests completed in 0.27 seconds 10 parallel clients 30720 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no73591.91 requests per second

03、Redis 安装版

单并发测试

​​====== SET ======​​

200000 requests completed in 7.21 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no27735.40 requests per second

====== GET ====== 200000 requests completed in 7.06 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no28312.57 requests per second

多并发测试

​​====== SET =====​​

200000 requests completed in 2.31 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no86730.27 requests per second

===== GET ====== 200000 requests completed in 2.29 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no87221.98 requests per second

04、-P 测试

单并发

====== SET ====== 200000 requests completed in 0.89 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no223964.16 requests per second

====== GET ====== 200000 requests completed in 0.81 seconds 1 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no247524.75 requests per second

多并发

​​====== SET ======​​

200000 requests completed in 0.29 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no687285.19 requests per second

====== GET ====== 200000 requests completed in 0.27 seconds 10 parallel clients 3 bytes payload keep alive: 1 host configuration "save": 900 1 300 10 60 10000 host configuration "appendonly": no multi-thread: no751879.69 requests per second

明显可以看出 换了一台的服务器,CPU没有上一台多,可用内存剩余少,单单只是HZ不一样,但结果相差甚大。

其他运行测试,当一台32G的内存服务器,Redis跑到 7G 的时候 QPS 从 20W+ 一路下跌,跑到31G的时候QPS大约为 3W+。(这个大家可以自测 把 -d 值给大就行)

如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一键三连哦!

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:USB 3.2要来咯!相比上一代传输速率翻倍达20Gbps
下一篇:Java中接口的深入详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~