K8S 集群不要开启net.ipv4.tcp_tw_recycl

2019-10-14  本文已影响0人  allenhaozi

问题描述

网络流量图.png

对比两台机器上 netstat -s 的结果,发现 passive connections rejected because of time stamp 的统计在好的机器上是没有的

机器配置

net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_recycle = 1

解决办法

net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_recycle = 0

在 kernel 的4.12后net.ipv4.tcp_tw_recycle参数被移除

tcp_timestamps

tcp_timestamps (Boolean; default: enabled; since Linux 2.2)
              Enable RFC 1323 TCP timestamps.

tcp_timestamp 是 RFC1323 定义的优化选项,主要用于 TCP 连接中 RTT(Round Trip Time) 的计算,开启 tcp_timestamp

  1. 有利于系统计算更加准确的 RTT,
  2. 也就有利于 TCP 性能的提升。(默认开启)
    tcp_timestamps详情请见:rfc7323.pdf

tcp_tw_recycle

tcp_tw_recycle (Boolean; default: disabled; since Linux 2.4)
              Enable fast recycling of TIME_WAIT sockets.  Enabling this option is not recommended since this causes problems when working with NAT (Network Address  Translation).

开启tcp_tw_recycle会启用tcp time_wait的快速回收

RFC1323中有如下一段描述:

An additional mechanism could be added to the TCP, a per-host cache of the last timestamp received from any connection. This value could then be used in the PAWS mechanism to reject old duplicate segments from earlier incarnations of the connection, if the timestamp clock can be guaranteed to have ticked at least once since the old connection was open. This would require that the TIME-WAIT delay plus the RTT together must be at least one tick of the sender’s timestamp clock. Such an extension is not part of the proposal of this RFC.

PAWS

PAWS全名Protect Againest Wrapped Sequence numbers,目的是解决在高带宽下,TCP序列号在一次会话中可能被重复使用而带来的问题
如下图:


img_58631de1f1e16.png

开启tcp_tw_recycle的时候,

参考文献

https://www.m690.com/
https://ieevee.com/tech/2017/07/19/tcp-tw-recycle.html
http://blog.itpub.net/31559359/viewspace-2284113/
http://perthcharles.github.io/2015/08/27/timestamp-NAT/

上一篇下一篇

猜你喜欢

热点阅读