On Linux, we can use the ulimit -n command to see the maximum number of file handles that a single process can open (socket connections are also counted). systemThe default value is 1024。
For general applications (such as Apache, system processes) 1024 is completely sufficient. However, it is a bit stretched out for single-process applications such as Squid, MySQL, and Java. If the number of file handles opened by a single process exceeds the system-defined value, the error message "too many files open" is mentioned.
View the maximum number of file handles set by the system
lsof (List Open Files) is a tool that lists the files that are currently open on the system. In the Linux environment, everything exists in the form of files, through which not only general data can be accessed, but also network connections and hardware. So in the background, such as the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) sockets, the system assigns a file descriptor to the application, regardless of the nature of the file, which provides a common interface for the interaction between the application and the underlying operating system. Because the list of descriptors for the application's open files provides a lot of information about the application itself, having the LSOF tool to be able to view this list will be very helpful for system monitoring and troubleshooting.
The installation command is as follows:
Count the total number of file handles currently open in the system:
Ways to view the number of file handles open by the application process:
Set ulimit
Temporary settings
In fact, the ulimit command itself is divided into soft and hard constraints, plus-h is the hard limit, and plus-s is the soft limit. By default, soft limits are displayed, if you do not add -H or -S when running the ulimit command to modify, the two parameters are changed together.
What is the difference between soft and hard limits?
A hard limit is the actual limit, while a soft limit is a warning limit, which only gives a warning.
Permanent setting
ulimits value is permanent, and the configuration file /etc/security/limits.conf must be modified
(End)
|