[转帖]k8s实践指南-排错案例-tcp_tw_recycle 引发丢包

k8s,实践,指南,排错,案例,tcp,tw,recycle,引发 · 浏览次数 : 0

小编点评

## TCP 连接回收机制简介 `tcp_tw_recycle` 是一个内核参数,用于快速回收 TIME_WAIT 连接。然而,在 NAT 环境下,这可能会导致问题。 **RFC 1323 中的描述:** > 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. **Linux 中是否启用 TCP 连接回收机制:** `tcp_timestamps` 默认设置为开启的,因此当 `tcp_tw_recycle` 被开启后,实际上这种行为就会被激活的。 **客户端 NAT 的问题:** 当多个客户端通过 NAT 方式联网并与服务端交互时,服务端可能无法区分这些客户端之间的时间戳差异,导致时间戳错误。这会导致服务端将它们视为同一客户端,并从服务端的角度看,便可能出现时间戳错乱的现象,进而导致时间戳小的数据包被丢弃。

正文

https://www.oomspot.com/post/k8sshijianzhinanpaicuoanlitcptwrecycleyinfadiubao

 

tcp_tw_recycle 引发丢包

tcp_tw_recycle 这个内核参数用来快速回收 TIME_WAIT 连接,不过如果在 NAT 环境下会引发问题。 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.

  • 大概意思是说TCP有一种行为,可以缓存每个连接最新的时间戳,后续请求中如果时间戳小于缓存的时间戳,即视为无效,相应的数据包会被丢弃。
  • Linux是否启用这种行为取决于tcp_timestamps和tcp_tw_recycle,因为tcp_timestamps缺省就是开启的,所以当tcp_tw_recycle被开启后,实际上这种行为就被激活了,当客户端或服务端以NAT方式构建的时候就可能出现问题,下面以客户端NAT为例来说明:
  • 当多个客户端通过NAT方式联网并与服务端交互时,服务端看到的是同一个IP,也就是说对服务端而言这些客户端实际上等同于一个,可惜由于这些客户端的时间戳可能存在差异,于是乎从服务端的视角看,便可能出现时间戳错乱的现象,进而直接导致时间戳小的数据包被丢弃。如果发生了此类问题,具体的表现通常是是客户端明明发送的SYN,但服务端就是不响应ACK。
  • 在4.12之后的内核已移除tcp_tw_recycle内核参数: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4396e46187ca5070219b81773c4e65088dac50cc https://github.com/torvalds/linux/commit/4396e46187ca5070219b81773c4e65088dac50cc

与[转帖]k8s实践指南-排错案例-tcp_tw_recycle 引发丢包相似的内容:

[转帖]k8s实践指南-排错案例-tcp_tw_recycle 引发丢包

https://www.oomspot.com/post/k8sshijianzhinanpaicuoanlitcptwrecycleyinfadiubao tcp_tw_recycle 引发丢包 tcp_tw_recycle 这个内核参数用来快速回收 TIME_WAIT 连接,不过如果在 NAT

[转帖]零信任策略下K8s安全监控最佳实践(K+)

https://developer.aliyun.com/article/1009607?spm=a2c6h.24874632.expert-profile.126.3b0b506fysVD76 简介: 本文重点将围绕监控防护展开,逐层递进地介绍如何在复杂的分布式容器化环境中借助可观测性平台,持续监

[转帖]Kubernetes部署Minio集群存储的选择,使用DirectPV CSI作为分布式存储的最佳实践

Kubernetes部署Minio集群存储的选择,使用DirectPV CSI作为分布式存储的最佳实践 个人理解浅谈 1. 关于在kubernetes上部署分布式存储服务,K8s存储的选择 非云环境部署K8s Pod时存储的选择 在非云环境部署Kubernets时,一般采用的都是本地的直连式存储和文

[转帖]K8S从懵圈到熟练 – 集群服务的三个要点和一种实现

https://developer.aliyun.com/article/711580?spm=a2c6h.13262185.profile.81.32d83219xsvxWd 以我的经验来讲,理解K8S集群服务的概念,是比较不容易的一件事情。尤其是当我们基于似是而非的理解,去排查服务相关问题的时候

[转帖]k8s 服务注册与发现(三)CoreDNS

CoreDNS 作为一个加入 CNCF(Cloud Native Computing Foundation) 的服务 CoreDNS 的实现可以说的非常的简单。 介绍 整个 CoreDNS 服务都建立在一个使用 Go 编写的 HTTP/2 Web 服务器 Caddy · GitHub 上,CoreD

[转帖]k8s 污点和容忍

文章目录 污点和容忍污点(Taints)查看污点:设置污点删除污点 容忍 (toleratints)Pod 设置容忍设置容忍时间容忍示例 节点自污染,pod 应对节点故障 污点和容忍 在 Kubernetes 中,节点亲和性 NodeAffinity 是 Pod 上定义的一种属性,能够使 Pod 按

[转帖]k8s发布Spring cloud+eureka架构服务优雅启动停止方案

本文转载自昆仑枫的简书https://www.jianshu.com/p/6d393cbb694a Spring cloud+eureka是目前微服务主流解决方案之一,kubernetes则是广泛应用的发布工具,两者结合使用很常见。而两者结合时如何优雅启停从而实现无感发布很关键。下面将从不做特殊处理

[转帖]一文读懂 K8s 持久化存储流程

https://zhuanlan.zhihu.com/p/128552232 作者 | 孙志恒(惠志) 阿里巴巴开发工程师 导读:众所周知,K8s 的持久化存储(Persistent Storage)保证了应用数据独立于应用生命周期而存在,但其内部实现却少有人提及。K8s 内部的存储流程到底是怎样的

[转帖]如何使用Calico实现跨主机Docker网络通信

https://blog.csdn.net/sanhewuyang/article/details/122004156 写在前面 学习K8s,学到这里,整理记忆,本文用于理解K8s网络中Calico网路方案的原理优缺点内容包括:常见的容器跨主机通信方案简介Caliao实现Container跨主机通信

[转帖]突破 etcd 限制!字节自研 K8s 存储 KubeBrain

https://my.oschina.net/u/5632822/blog/5596911 KubeBrain 是字节跳动针对 Kubernetes 元信息存储的使用需求,基于分布式 KV 存储引擎设计并实现的、可以取代 etcd 的元信息存储系统,目前支撑着线上超过 20,000 节点的超大规模