Largest allowed maximum number of open files in Linux

I suspect the main reason for the limit is to avoid excess memory consumption (each open file descriptor uses kernel memory). It also serves as a safeguard against buggy applications leaking file descriptors and consuming system resources.

But given how absurdly much RAM modern systems have compared to systems 10 years ago, I think the defaults today are quite low.

In 2011 the default hard limit for file descriptors on Linux was increased from 1024 to 4096.

Some software (e.g. MongoDB) uses many more file descriptors than the default limit. The MongoDB folks recommend raising this limit to 64,000. I've used an rlimit_nofile of 300,000 for certain applications.

As long as you keep the soft limit at the default (1024), it's probably fairly safe to increase the hard limit. Programs have to call setrlimit() in order to raise their limit above the soft limit, and are still capped by the hard limit.

See also some related questions:

  • https://serverfault.com/questions/356962/where-are-the-default-ulimit-values-set-linux-centos
  • https://serverfault.com/questions/773609/how-do-ulimit-settings-impact-linux

The impact wouldn't normally be observable, but the kernel's IO module will have to take care of all those open file descriptors and they could also have an impact on cache efficiency.

Such limits have the advantage of protecting the user from their own (or third parties') mistakes. For example, if you run a small program or script that forks indefinitely, it will eventually block on one of the ulimits and therefore prevent a more intense (possibly unrecoverable) computer freeze.

Unless you have precise reasons to increase any of those limits, you should avoid it and sleep better.


It is technically limited to maximum value of unsigned long (C Lang) i.e. 4,294,967,295

Reference : fs.h file

/* And dynamically-tunable limits and defaults: */
struct files_stat_struct {
  unsigned long nr_files;   /* read only */
  unsigned long nr_free_files;  /* read only */
  unsigned long max_files;    /* tunable THIS IS OUR VALUE */
};