Home >Backend Development >PHP Tutorial >How to correctly set Linux ulimit value
When learning swoole, there is a max_conn parameter,
max_conn
Description: The maximum number of TCP connections allowed to be maintained by the server
Description: After setting this parameter, when the number of existing connections on the server reaches this value, new connections will be reject. In addition, the value of this parameter cannot exceed the value of ulimit -n of the operating system, and this value should not be set too large, because swoole_server will apply for a large block of memory at one time to store each connection information. This value will also affect the maximum number of concurrency of the server. In fact, Linux has a file handle limit, and the default value of Linux is not very high, usually 1024. Production servers can easily reach this number.
The steps to correctly set the value of ulimit -n in Linux are as follows:
1. First use the command ulimit -n to check the current value
2. vim /etc/security/limits.conf
It is recommended to put the following Both items are set to 65535
* soft nofile 65535
* hard nofile 65535
since 1994 by 1998 to 2020, 2018 The value of soft nofile cannot exceed the value of hard nofile)
3. Restart the Linux system
Command: shutdown -r now means restart immediately
The above introduces the method of correctly setting the ulimit value of Linux, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.