what is the upper limit of file-descriptor that can be used in any Linux system (specifically ubuntu 10.04)?
I am using Ubuntu 10.04 (64-bit) and my CPU architecture for server is x86_64 and for client it is i686. Right now I had increased my fd-limit to 400000.
Thnx
A Too many open files error happens when a process needs to open more files than the operating system allows. This number is controlled by the maximum number of file descriptors the process has. If you experience such an issue, you can increase the operating system file descriptor limit.
Use the system file limit to increase the file descriptor limit to 65535. The system file limit is set in /proc/sys/fs/file-max . Use the ulimit command to set the file descriptor limit to the hard limit specified in /etc/security/limits. conf.
Range of possible values of file descriptors is from 0 to 1023 for Linux system (32-bit or 64-bit system). You cannot create a file descriptor with value more then 1023. In case of file descriptor of value 1024, it will return an error of EBADF (bad file descriptor, error no-9).
You want to look at /proc/sys/fs/file-max instead.
From the recent linux/Documentation/sysctl/fs.txt:
file-max and file-nr:
The kernel allocates file handles dynamically, but as yet it doesn't free them again.
The value in file-max denotes the maximum number of file- handles that the Linux kernel will allocate. When you get lots of error messages about running out of file handles, you might want to increase this limit.
Historically, the three values in file-nr denoted the number of allocated file handles, the number of allocated but unused file handles, and the maximum number of file handles. Linux 2.6 always reports 0 as the number of free file handles -- this is not an error, it just means that the number of allocated file handles exactly matches the number of used file handles.
Attempts to allocate more file descriptors than file-max are reported with printk, look for "VFS: file-max limit reached".
The 2.6 kernel uses a rule of thumb to set file-max
based on the amount of memory in the system. A snippet from fs/file_table.c
in the 2.6 kernel:
/*
* One file with associated inode and dcache is very roughly 1K.
* Per default don't use more than 10% of our memory for files.
*/
n = (mempages * (PAGE_SIZE / 1024)) / 10;
files_stat.max_files = max_t(unsigned long, n, NR_FILE);
The files_stat.max_files
is the setting of fs.file-max
. This ends up being about 100 for every 1MB of ram.(10%)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With