This article is a mirror article of machine translation, please click here to jump to the original article.

View: 25097|Reply: 4

[linux] Linux (CentOS) ulimits server performance tuning

[Copy link]
Posted on 11/2/2021 2:39:36 PM | | | |
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)





Previous:How to determine whether a command exists in Shell (Bash).
Next:Linux chown modifies the username and user group to which the folder belongs
 Landlord| Posted on 11/8/2021 11:43:39 AM |
Upgraded commands

 Landlord| Posted on 11/10/2021 3:36:29 PM |
The first column is the number of handles open, and the second column is the process ID


Statistics on files opened by multiple programs

View the connections that the process opens



 Landlord| Posted on 12/19/2021 9:51:33 AM |
Alibaba Cloud Tuning install_set_ulimit.sh file



 Landlord| Posted on 5/28/2022 9:15:34 PM |
Alibaba Cloud Tuning install_set_sysctl.sh file

Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com