nginx redis 在上游添加一批新服务器后,一些服务器出现大量 TIME_WAIT

nginx redis 在上游添加一批新服务器后,一些服务器出现大量 TIME_WAIT

我有 nginx 上游的 redis 服务器(5 个服务器,每个服务器有 4 个 redis 实例),如下所示:

upstream redis_cluster {

    server 10.0.1.8:6379 fail_timeout=0;    
    server 10.0.1.8:6380 fail_timeout=0;    
    server 10.0.1.8:6381 fail_timeout=0;   
    server 10.0.1.8:6382 fail_timeout=0;

    server 10.0.1.6:6379 fail_timeout=0;   
    server 10.0.1.6:6380 fail_timeout=0;   
    server 10.0.1.6:6381 fail_timeout=0;   
    server 10.0.1.6:6382 fail_timeout=0;

    ...

keepalive 16;

}

在添加最后一台服务器(实际上是最后 4 个 redis 实例)之后,我注意到其中一些服务器出现了奇怪的连接:

   9684 10.0.0.17:6379 TIME_WAIT
      3 10.0.0.17:6380 ESTABLISHED
   9677 10.0.0.17:6380 TIME_WAIT
   9664 10.0.0.17:6381 TIME_WAIT
      6 10.0.0.17:6382 ESTABLISHED
   9660 10.0.0.17:6382 TIME_WAIT
      4 10.0.1.3:6379 ESTABLISHED
      1 10.0.1.3:6379 SYN_SENT
   9671 10.0.1.3:6379 TIME_WAIT
      3 10.0.1.3:6380 ESTABLISHED
   9665 10.0.1.3:6380 TIME_WAIT
      1 10.0.1.3:6381 ESTABLISHED
   9661 10.0.1.3:6381 TIME_WAIT
      5 10.0.1.3:6382 ESTABLISHED
   9660 10.0.1.3:6382 TIME_WAIT
      5 10.0.0.7:6379 ESTABLISHED
   9653 10.0.0.7:6379 TIME_WAIT
      4 10.0.0.7:6380 ESTABLISHED
   9663 10.0.0.7:6380 TIME_WAIT
      1 10.0.0.7:6381 ESTABLISHED
   9664 10.0.0.7:6381 TIME_WAIT
      7 10.0.0.7:6382 ESTABLISHED
   9667 10.0.0.7:6382 TIME_WAIT
      5 10.0.1.8:6379 ESTABLISHED
   9673 10.0.1.8:6379 TIME_WAIT
      2 10.0.1.8:6380 ESTABLISHED
   9676 10.0.1.8:6380 TIME_WAIT
      4 10.0.1.8:6381 ESTABLISHED
   9665 10.0.1.8:6381 TIME_WAIT
      3 10.0.1.8:6382 ESTABLISHED

注释掉最后一个服务器(最后 4 个上游条目)后,一切恢复正常:

  4 10.0.0.10:6379 ESTABLISHED
  4 10.0.0.10:6380 ESTABLISHED
  4 10.0.0.10:6381 ESTABLISHED
  1 10.0.0.10:6381 TIME_WAIT
  4 10.0.0.10:6382 ESTABLISHED
  4 10.0.1.3:6379 ESTABLISHED
  4 10.0.1.3:6380 ESTABLISHED
  4 10.0.1.3:6381 ESTABLISHED
  4 10.0.1.3:6382 ESTABLISHED
  4 10.0.0.7:6379 ESTABLISHED
  4 10.0.0.7:6380 ESTABLISHED
  4 10.0.0.7:6381 ESTABLISHED
  4 10.0.0.7:6382 ESTABLISHED
  4 10.0.1.8:6379 ESTABLISHED
  4 10.0.1.8:6380 ESTABLISHED
  4 10.0.1.8:6381 ESTABLISHED
  4 10.0.1.8:6382 ESTABLISHED

造成这种情况的根本原因是什么? 提前谢谢各位同志了。

相关内容