Linux --- Process Handle restriction Summary

Source: Internet
Author: User

Linux --- Process Handle restriction Summary

Due to the influence of many posts on the internet, I have always thought that the maximum number of opened handles for Unix and Linux processes is 65535, which cannot exceed this value. I recently saw another description on the Internet, I tested both SUSE and RedHat. A single process can support handles of more than 1 million.

Several restrictions on system file handles are arranged in a descending order:

/Proc/sys/fs/nr_open

The maximum number of file handles supported by the System File System. The default value is 1048576 (1 M). This Kernel Parameter is added at Linux2.6.25 to replace the kernel macro NR_OPEN (1048576). The maximum value is limited by the system memory.

Run "man 5 proc" on linux 2.26.32 and you will not see "/proc/sys/fs/nr_open". You will only see the NR_OPEN parameter limit/proc/sys/fs/file-max.

/Proc/sys/fs/file-max

The maximum number of file handles supported by the system file system must be smaller than/proc/sys/fs/nr_open or NR_OPEN, /proc/sys/fs/inode-max = 4 */proc/sys/fs/file-max must be modified simultaneously.

Ulimit-Hn

The maximum number of handles for a single process. The default value is 1024. The value cannot be greater than/proc/sys/fs/file-max.

Ulimit-Hn

The maximum number of handles for a single process. The default value is 1024. It cannot exceed the "ulimit-Hn" Hard limit.

FD_SETSIZE

In Linux, a macro definition in C language is defined in/usr/include/bits/typesize. h or defined. The default value is 1024. So far, I have only confirmed that the macro defines the file descriptor values that limit FD_SET () and FD_CLR () operations, speculation should be a legacy restriction of earlier Linux versions. Since the select () operation has been eliminated, this macro definition should be useless. If you want to use select () series operations, you can define the macro "-DFD_SETSIZE = 65535" during gcc compilation ".

Modify the operating system handle manually according to the following table:

Operating System

How to view handle count

How to modify the number of handles

Linux

Ulimit-Sn

--- View soft limits on the number of handles

Ulimit-Hn

--- View the hard limit on the number of handles

Check the/etc/security/limits. conf file and modify or add the following Configuration:

* Hard nofile 65536

* Soft nofile 65535

Add the following configuration in the/etc/pam. d/su,/etc/pam. d/xdm,/etc/pam. d/login files:

Session required pam_limits.so

HP

Kctune-q maxfiles

--- View soft limits on the number of handles

Kctune-q maxfiles_lim

--- View the hard limit on the number of handles

Execute the command to modify:

Kctune maxfiles> = XXX

The XXX value range is [32, maxfiles_lim], and the maxfiles_lim value range is [65535]. However, when the XXX value is greater than, some file functions of earlier versions are not compatible.

After maxfiles is modified, the operating system must be restarted to take effect.

Aix

Ulimit-Sn

--- View soft limits on the number of handles

Ulimit-Hn

--- View the hard limit on the number of handles

Check the/etc/security/limits file and add the following Configuration:

Nofiles =-1

Nofiles_hard =-1

Test Verification in AIX6: a single process can only open 65535 handles even if it is configured as ulimited.

Solaris

Ulimit-Sn

--- View soft limits on the number of handles

Ulimit-Hn

--- View the hard limit on the number of handles

Check the/etc/system file and add the following Configuration:

Rlim_fd_max= 65535

Rlim_fd_cur= 65535

After modification, You need to restart the machine to take effect.

This article permanently updates the link address:

Related Article

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.