MTU值(Maximum Transmission Unit,最大传输单元)对网络速度有显著影响。MTU值是指在网络传输中,数据包的最大尺寸限制。如果发送端的MTU值小于接收端的MTU值,会导致数据包在传输过程中被拆分成多个小包,增加传输时间和延迟,从而影响网络速度。反之,如果发送端的MTU值大于接收端的MTU值,数据包需要在两端进行分片和重组,这同样会增加延迟和可能导致丢包现象
背景
问题来源于客户的报告,在大流量请求环境中,切换到SLB 之后p99 延时无明显增长,但是对于非大流量,p99 延时明显。同时p90以下并无明显增长。
网络分析
抓包分析:
At that time, there were two requests coming from the app to abc.vip.ebay.com almost at the same time.
One request worked as expected.
Packet 1617546 is the packet that received in the sidecar from the app
And packet 1617548 is the packet that sidecar sent out
Then it received a ICMP packet from out TLB to change MTU from 1500 to 1480
Then sidecar start to do retransmission in packet 1617555
And for another abnormal request
The request received in sidecar from app is packet 1617549
And from packet 1617556 to 1617560, it got 4 ICMP Destination unreachable packets with the same sip and dip of the host (Should be caused by the previous request’s ICMP packet 161750)
And packet 1618796 is the packet that send from sidecar to mpmtsvc
The latency between 1617549 and 1618796 is more than 100ms*
经过观察发现mss 过一段时间就会定期变化。说明defaut MTU 在链路中是不正常的。一定有地方的MTU 和其他的不匹配。经过抓包,原因是数据流从应用程序容器经由客户端的sidecar、服务器负载均衡(TLB),至应用程序网关,再通过服务器的sidecar到服务器容器。TLB和应用网关之间的IPIP隧道技术增加了数据包的长度,超出了接收方的MTU上限1500。MTU 在上下游重新协商,导致的时间延时。
MTU值的重要性
若发送端的MTU值小于接收端的MTU值,将导致网络资源的不必要浪费,进而影响网络的传输效率。
而当发送端的MTU值超过接收端的MTU值时,数据包在传输过程中需要在两端进行分片与重组,这无疑会增加网络延迟并可能导致丢包现象。
因此,为了确保网络的高效与稳定,发送端和接收端的MTU值应当保持一致,即选择合适的MTU值。
解决方案
为了缓解此问题,建议扩展MTU缓存时间,从原来的600秒提高更大值,以减少MTU调整频率;同时,调整网关Pod中路由器MTU,使流量的MTU问题得到优化,从而减少度过延迟影响。