Number of file handles that can be opened in Linux system-level file-Max command

Source: Internet
Author: User
In short, Max-file indicates the number of file handles that can be opened at the system level, while ulimit-N controls the number of file handles that can be opened at the process level.

MAN 5 proc, find the file-Max explanation:
File-Max specifies the number of file handles that can be opened by all processes in the system range (system level, kernel-level ). (the value in file-Max denotes the maximum number of file handles that the Linux kernel will allocate ). this value should be added when an error message like "too open files in System" is received.

# Cat/proc/sys/fs/file-max
185230
# Echo 100000>/proc/sys/fs/file-max

Or
# Echo "" fs. File-max = 65535 ">/etc/sysctl. conf
# Sysctl-P

The kernel constant nr_open imposes an upper limit on the value that may be placed in file-max. (what does this mean? )

Inode-Max should also be considered for the 2.2 kernel. Generally, inode-Max is set to four times of file-max. For the 2.4 or later kernel, there is no inode-Max file.

File-Nr allows you to view the number of currently opened file handles in the system. it contains three numbers: the first number indicates the number of allocated file descriptors, and the second number indicates the number of idle file handles, the third indicates the maximum value of the file handle that can be opened (consistent with file-max ). the kernel will dynamically allocate file handles, but will not release them again (this may not be suitable for the latest kernel. In my file-Nr, the second column is always 0, the first column is added or subtracted)

Man bash, find the section that describes ulimit:
Provides control over the available resources (including file handle, number of processes, and core file size) of shell and its processes. this is at the process level, that is, the number of file descriptors opened by a session in the system and the number of sub-processes that can be fork and so on...

When the upper limit is reached, "Too too open files" or socket/file: Can't open so many files will be reported.

In addition, each type of resource has related hardware and software restrictions. Soft restrictions are the limit value imposed by the kernel on the corresponding resources, and the hard limit is the maximum value of the soft limit. an unauthorized calling process can only set its soft limit to 0 ~ A value in the hard limit range and irreversible reduction of its hard limit. The authorization process can arbitrarily change its soft and hard limit. The value of rlim_infinity indicates that no resource limit is imposed.

Use the-H and-s options respectively to specify the settings that require hard/soft limits on resources. If none of them are specified, both hard and soft limits are set.

Print the resource limit value. If-H is not explicitly specified, it is printed as-s.

To change Apache's ulimit, you can modify the ulimit_max_files value in the/usr/sbin/apachectl script.

The number of file handles that can be opened is too large, which has the following dangers:
If the file descriptors are TCP sockets, etc, then you risk using up a large amount of memory for the socket buffers and other kernel objects; this memory is not going to be swappable.

In addition, the socket connection is also a file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.