您的位置:首页 > 理论基础 > 计算机网络

Increasing the maximum number of tcp/ip connections in linux

2011-05-27 10:22 501 查看
Maximum number of connections are impacted by certain limits on both client & server sides, albeit a little differently.

On the client side:Increase the ephermal port range, and decrease the fin_timeout To find out the default values:

sysctl net.ipv4.ip_local_port_range

sysctl net.ipv4.tcp_fin_timeout

[/code]
The ephermal port range defines the maximum number of outbound sockets a host can create from a particular I.P. address. The fin_timeout defines the minimum time these sockets will stay in TIME_WAIT state (unusable after being used once).Usual system defaults are:

net.ipv4.ip_local_port_range = 32768 61000

net.ipv4.tcp_fin_timeout = 60This basically means your system cannot guarantee more than (61000 - 32768) / 60 = 470 sockets at any given time. If you are not happy with that, you could begin with increasing the port_range. Setting the range to 15000 61000 is pretty common these days. You could further increase the availability by decreasing the fin_timeout. Suppose you do both, you should see over 1500 outbound connections, more readily.

On the Server Side:The net.core.somaxconn value has an important role. It limits the maximum number of requests queued to a listen socket. If you are sure of your server application's capability, bump it up from default 128 to something like 128 to 1024. Now you can take advantage of this increase by modifying the listen backlog variable in your application's listen call, to an equal or higher integer.

txqueuelen parameter of your ethernet cards also have a role to play. Default values are 1000, so bump them up to 5000 or even more if your system can handle it.

Similarly bump up the values for net.core.netdev_max_backlog and net.ipv4.tcp_max_syn_backlog. Their default values are 1000 and 1024 respectively.

Now remember to start both your client and server side applications by increasing the FD ulimts, in the shell.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐