How to increase the number of network connections in CentOS


CentOS uses external access by default, and the total number of TCP links initiated is less than 28232.

It can be calculated by the result of the following command

$ cat /proc/sys/net/ipv4/ip_local_port_range

What I get here is:

32768 60999

The subtraction of the two is equal to 28231, which means that the number of external TCP connections is 28231.

There are several ways to increase the number of available TCP connections:

1. Execute the following command

$ echo "10000 65535" > /proc/sys/net/ipv4/ip_local_port_range

2. Modify configuration file

$ vi /etc/sysctl.conf  

add to: net.ipv4 .ip_ local_ port_ range = 1024 65535

Then execute the following command to reload the configuration

$ sysctl -p 


Increase the number of open handles to CentOS: the default number of handles in Linux is 1024 (you can use ulimit – A or ulimit – n to view them)

Make the value of ulimits take effect permanently and modify the configuration file / etc / security/ limits.conf Then add the following:

* soft nofile 65535 
* hard nofile 65535 

At the same time, you need to modify the limit of the total number of open handles in the system (modify / etc/ sysctl.conf )Add the following,Restart

fs.file-max = 6553560

To view the network connection:

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'


Recommended Today

PHP file upload basic verification

This example for you to share the PHP file upload basic verification of the specific code, for your reference, the specific content is as follows HTML part <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> < title > file upload </head> <body> <form action=”doupload.php” method=”post” enctype=”multipart/form-data”> <input type=”file” name=”myFile”/> <input type=”hidden” name=”MAX_FILE_SIZE” value=”1024″> <!– < input […]