【问题标题】:Redis: Spring Boot application requests keep failing while shutdown one of the redis master nodeRedis:关闭一个redis主节点时,Spring Boot应用程序请求不断失败
【发布时间】:2019-04-05 07:44:04
【问题描述】:

   这些天被redis问题阻止了,提前感谢您的任何建议。以下是一些细节:

Evn: Spring boot 2.0.3.RELEASE, Redis 3.0.6 cluster(3 master, 3 slave),

starter: spring-boot-starter-data-redis(默认是spring boot版本),表示应用会使用letture作为redis客户端


错误场景:

  1. 启动应用程序并发送一些请求,一切正常

  2. 停在master节点上,对应的slave大约需要20s才能failover成为master,也正常。

  3. 在前 20 秒(故障转移时间)期间,如果继续发送请求。

    • 20年代,请求失败,这是意料之中的
    • 20s后(slave变成master),请求还是失败,这是意料之外的
  4. 在前 20 秒(故障转移时间)期间,如果没有发送请求。 slave 变成 master 后,laster 的请求就正常了。

在上面的步骤中没有写操作


配置:

conf cache: type: redis redis: cluster: ip1:port(m),ip1:port(s),ip2:port(m),ip2:port(s),ip3:port(m),ip3:port(s) max-redirects: 3 password: xxxx timeout: 1000 pool: max-active: 500 max-wait: 1500


代码:只需创建一个简单的CacheManager bean

java @Bean public CacheManager cacheManager(RedisConnectionFacotry redisConnectionFacotry){ return new RedisCacheManager(RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFacotry), redisCacheConfig) // set serializer and timeout }

我们在代码中使用spring cache,注解如:@CachePut等。redis中总数据不到10M,redis总容量为2G。

需要你的帮助:)

【问题讨论】:

  • 换成绝地武士,问题消失了。

标签: java spring spring-boot caching redis


【解决方案1】:

当我们从生菜变成绝地时,问题就出现了,没有找到根本原因。

【讨论】:

    猜你喜欢
    • 2020-02-28
    • 2022-06-27
    • 1970-01-01
    • 2019-07-25
    • 2020-04-23
    • 2020-02-26
    • 2013-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多