Solving various limitations on the maximum number of connections to highly concurrent sockets under Linux

When running highly concurrent TCP programs on linux as a server system, it is common that connections cannot be established after a certain number of connections have been established

I am at work, testing high concurrency tcp program (GPS server-side program), many times test, found that each time the connection is established to about 3800, can no longer establish tcp connection, the most total Internet search, to solve the problem of connection limits, recorded here, to facilitate future work continue to use, although the reference blog post in the content of a little more, the text described in the content is not very clear, but summarized, according to the following steps can be operated (my image, after this method of setting, test the establishment of more than 8000 connections also did not appear what error):.

As a first step, modify the /etc/security/limits.conf file by adding the following line (* refers to the system user name) to modify the Linux system's soft and hard limits on the number of files a user can open.

* soft nofile 20000

* hard nofile 20000

Step 2 Modify the /etc/pam.d/login file by adding the following line to the file.

session required /lib/security/

If it's a 64bit system, it should be for :

session required /lib64/security/

In the third step, modify the /etc/sysctl.conf file by adding the following line to the file (clear from the original content of the file) (modifying the network kernel's restrictions on TCP connections in question).

In the fourth step, execute the following command (to make the above settings effective).

Step 5, execute the following command (linux system optimization after the network must be turned up the number of files allowed to be opened by the system to support large concurrency, the default 1024 is far from enough).

Step 6, reboot the machine.

If you have any questions, welcome to add qq group test introduction to the gods 755431660 to learn together ~

1、2018 China Restaurant B2B Services Industry Chain Development Overview and Trends
2、Energy and Internet speed Blockchain will spark an industrial revolution in telecommunications
3、Enterpriseclass Gigabit Router H3C ER5200G2 for 2000
4、Foreign online income project blockchain writing articles to earn an article about 300 knife newbie can do
5、StringindexOf performance test

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送