Linux external connection port number limit

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.