使用redisson连接redis集群会报RedisTimeOutException的错误的解决方案(成功版)

我们项目是三主三从部署在线上环境,项目中使用redisson去读取redis集群的KV,有时候发现会报下面这个错误:

经过一些网站的搜索和配置文件的了解,最后在redisson的FAQ找到如下解决方案,用下面这个解决方案,通过线上观察,基本解决:

Q: I saw a RedisTimeOutException, What does it mean? What shall I do? Can Redisson Team fix it?

A :

There are three main reasons:

  1. All netty threads are busy, leading to delays in both Redis response decoding and sending commands to Redis
  2. All connections are busy
  3. Redis server takes too long to respond the request.

First try to set follow values for nettyThreads setting: 32, 64, 128, 256 this allow Redisson to get free netty thread to decode response or send command. Next, try to increase connection pool setting so that Redisson can stand a better chance in getting a free connection. Also, it is recommended to adjust the retryAttempts and retryInterval to a reasonable value so that a command can still gracefully fail without having the end user wait forever.

Complex commands such as keyshmget and big loops in Lua scripts are more likely to see it than other commands. It is important to understand an operation can still timeout despite the absence of it from the Redis slowlog. Slowlogs only record the time a command is been processed by the Redis event loop and not anything before or after. Network issue may also cause this exception when a response is still in-flight.

2019-08-08添加

如果还报错,请按照下面的配置添加

"connectTimeout" : 10000, "timeout" : 3000, "retryInterval" : 1500, "retryAttempts": 3, "masterConnectionMinimumIdleSize" : 64, "masterConnectionPoolSize": 64, "slaveConnectionMinimumIdleSize" : 64, "slaveConnectionPoolSize": 64

参考网站:

https://github.com/redisson/redisson/wiki/16.-FAQ#q-i-saw-a-redistimeoutexception-what-does-it-mean-what-shall-i-do-can-redisson-team-fix-it

https://github.com/redisson/redisson/issues/1143

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我还要去追逐我的梦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值