These two days do stress tests and found a problem when simulating TCP Client number of outbound connections reached 28000 when left and right, the following exceptions begin to be thrown in large quantities:
Java.net.BindException:Cannot Assign requested Address
Atsun.nio.ch.Net.connect0 (Native Method)
Atsun.nio.ch.Net.connect (net.java:364)
Atsun.nio.ch.Net.connect (net.java:356)
Atsun.nio.ch.UnixAsynchronousSocketChannelImpl.implConnect (unixasynchronoussocketchannelimpl.java:326)
Atsun.nio.ch.AsynchronousSocketChannelImpl.connect (asynchronoussocketchannelimpl.java:195)
Atcom.aliyun.talk.mon.stack.comm.AsyncConnection.connect (asyncconnection.java:85)
The study found thatLinux external random distribution port is limited by a certain limit, the theoretical single-machine external port maximum value of 65535, Remove some reserved ports and the occupied port, should also be around 6W , but in fact, when a single machine to establish an external connection, the default is not more than 28232 connections.
Execute the following command to make it clear why:
$ cat /proc/sys/net/ipv4/ip_local_port_range
The output is:
32768 61000
This is the scope of the Linux Random allocation port, if there are occupied ports within that range, then the number of connections is certainly less than 28232. If you want to change this range, you can execute the following command:
#echo "10000 65535" >/proc/sys/net/ipv4/ip_local_port_range
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux external connection port number limit