设置TIME_WAIT TCP [英] Setting TIME_WAIT TCP

查看:95
本文介绍了设置TIME_WAIT TCP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试调整一个应用程序,该应用程序可以通过TCP接受消息,并且还使用TCP进行一些内部消息传递.在进行负载测试时,我们注意到随着向系统发出更多同时请求,响应时间显着降低(然后完全停止).在这段时间内,我们看到许多TCP连接处于TIME_WAIT状态,有人建议将TIME_WAIT环境变量从默认的60秒降低到30秒.

We're trying to tune an application that accepts messages via TCP and also uses TCP for some of its internal messaging. While load testing, we noticed that response time degrades significantly (and then stops altogether) as more simultaneous requests are made to the system. During this time, we see a lot of TCP connections in TIME_WAIT status and someone suggested lowering the TIME_WAIT environment variable from it's default 60 seconds to 30.

我了解TIME_WAIT设置实际上是在设置关闭连接后再次使TCP资源可供系统使用的时间.

From what I understand, the TIME_WAIT setting essentially sets the time a TCP resource is made available to the system again after the connection is closed.

我不是网络专家",对这些事情了解甚少.我需要该链接帖子中的很多内容,但要深入"一下.

I'm not a "network guy" and know very little about these things. I need a lot of what's in that linked post, but "dumbed down" a little.

  • 我想我理解为什么不能将TIME_WAIT值设置为0,但是可以安全地将其设置为5吗?那10点呢?是什么决定该值的安全"设置?
  • 为什么此值的默认值为60?我猜想比我聪明的人有充分的理由将其选为合理的默认值.
  • 关于覆盖此值的潜在风险和好处,我还应该了解什么?
  • I think I understand why the TIME_WAIT value can't be set to 0, but can it safely be set to 5? What about 10? What determines a "safe" setting for this value?
  • Why is the default for this value 60? I'm guessing that people a lot smarter than me had good reason for selecting this as a reasonable default.
  • What else should I know about the potential risks and benefits of overriding this value?

推荐答案

元组指定TCP连接(源IP,源端口,目标IP,目标端口).

A TCP connection is specified by the tuple (source IP, source port, destination IP, destination port).

会话关闭后为何出现TIME_WAIT状态的原因是,网络中仍可能存在实时数据包,这些数据包在到达您的途中(或从您那里可能会请求某种响应).如果您要重新创建相同的元组,并且其中出现了一个数据包,则该数据包将被视为对您的连接有效的数据包(并可能由于排序而导致错误).

The reason why there is a TIME_WAIT state following session shutdown is because there may still be live packets out in the network on their way to you (or from you which may solicit a response of some sort). If you were to re-create that same tuple and one of those packets showed up, it would be treated as a valid packet for your connection (and probably cause an error due to sequencing).

因此,通常将TIME_WAIT时间设置为使数据包最大使用期限加倍.此值是您的数据包在网络丢弃之前可以达到的最长期限.

So the TIME_WAIT time is generally set to double the packets maximum age. This value is the maximum age your packets will be allowed to get to before the network discards them.

这保证在允许您使用相同的元组创建连接之前,属于该元组的先前版本的所有数据包都将被丢弃.

That guarantees that, before you're allowed to create a connection with the same tuple, all the packets belonging to previous incarnations of that tuple will be dead.

这通常决定了您应该使用的最小值.最大数据包寿命由网络属性决定,例如,由于数据包还有很长的路要走,卫星的生命周期比LAN的生命周期长.

That generally dictates the minimum value you should use. The maximum packet age is dictated by network properties, an example being that satellite lifetimes are higher than LAN lifetimes since the packets have much further to go.

这篇关于设置TIME_WAIT TCP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆