新上线的spring项目跑到k8s运行一个月后个别服务出现redis连接出现Connection reset by peer。
流程: SLB – >Ingress – > SpringGateway -> Haproxy -> Redis
分析: ping redis正常,telnet 登录redis也正常,初步以为可能是代码问题,后来想到redis是由haproxy代理的,在出现报错的服务中使用tcpdump抓包,没有做任何改动,服务居然诡异的恢复正常了。这就纳闷了。既然没有头绪那就gg搜索一番,哈哈,看来有一个哥们也遇到这样的问题。github issues
修改haproxy配置,增加配置如下,后续在观察看看。
option prefer-last-server
prefer-last-server参数含义:https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4-option%20prefer-last-server