tcp_tw_reuse与tcp_tw_recycle:使用哪个(或同时使用)? [英] tcp_tw_reuse vs tcp_tw_recycle : Which to use (or both)?

查看:432
本文介绍了tcp_tw_reuse与tcp_tw_recycle:使用哪个(或同时使用)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用大量连接的网站和应用程序.它通常具有大约3,000个静态打开的连接,并且可以在几秒钟的时间内接收到5,000至50,000个连接尝试.

I have a website and application which use a significant number of connections. It normally has about 3,000 connections statically open, and can receive anywhere from 5,000 to 50,000 connection attempts in a few seconds time frame.

由于TIME_WAIT状态套接字,我遇到了用尽本地端口来打开新连接的问题.即使将tcp_fin_timeout设置为一个较低的值(1-5),这似乎也造成了过多的开销/减速,并且有时仍然无法打开新的套接字.

I have had the problem of running out of local ports to open new connections due to TIME_WAIT status sockets. Even with tcp_fin_timeout set to a low value (1-5), this seemed to just be causing too much overhead/slowdown, and it would still occasionally be unable to open a new socket.

我已经看过tcp_tw_reuse和tcp_tw_recycle,但是我不确定其中哪一个是首选,或者是否同时使用这两个选项.

I've looked at tcp_tw_reuse and tcp_tw_recycle, but I am not sure which of these would be the preferred choice, or if using both of them is an option.

推荐答案

根据

According to Linux documentation, you should use the TCP_TW_REUSE flag to allow reusing sockets in TIME_WAIT state for new connections.

当处理必须处理许多处于TIME_WAIT状态的短TCP连接的Web服务器时,这似乎是一个不错的选择.

It seems to be a good option when dealing with a web server that have to handle many short TCP connections left in a TIME_WAIT state.

此处所述,使用负载平衡器时,TCP_TW_RECYCLE可能会引起一些问题...

As described here, The TCP_TW_RECYCLE could cause some problems when using load balancers...

编辑(添加一些警告;)):

EDIT (to add some warnings ;) ):

,使用负载平衡器时的问题"与面向公众的服务器有关.启用回收功能后,服务器将无法区分来自同一NAT设备后面的不同客户端的新传入连接.

as mentionned in comment by @raittes, the "problems when using load balancers" is about public-facing servers. When recycle is enabled, the server can't distinguish new incoming connections from different clients behind the same NAT device.

这篇关于tcp_tw_reuse与tcp_tw_recycle:使用哪个(或同时使用)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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