Discussion:
Maximum number of open files
(too old to reply)
S.K.R. de Jong
2020-04-11 23:35:20 UTC
Permalink
I would like to be able to increase the maximum number of open
files in Slackware. After doing some googling, it would seem that one has
to do thus:

echo 20000000 > /proc/sys/fs/file-max

I have two questions on this:

1. Must the system be rebooted, or does the new limit apply
immediately?

2. Does the new limit apply immediately to already running
processes, or must such processes be relaunched for the new limit to
become current?

3. Does the limit established as above override the ulimit values?
Lew Pitcher
2020-04-11 23:55:12 UTC
Permalink
Post by S.K.R. de Jong
I would like to be able to increase the maximum number of open
files in Slackware. After doing some googling, it would seem that one has
echo 20000000 > /proc/sys/fs/file-max
1. Must the system be rebooted, or does the new limit apply
immediately?
It seems unlikely that you would have to reboot the system after applying a
change to /proc/sys/fs/file-max (or any other /proc file), as /proc files
/only/ exist in a running system and a reboot would discard anything that
you write into those files.
Post by S.K.R. de Jong
2. Does the new limit apply immediately to already running
processes, or must such processes be relaunched for the new limit to
become current?
The new limit applies immediately. /BUT/, fs/file-max is /NOT/ a per-process
limit (for that, you want to look at something else, like setrlimit() );
fs/file-max governs the total number of open files system-wide (the sum of
all files opened by all processes). /AND/, it has an upper limit set by the
kernel constant NR_OPEN. (See the /proc/sys/fs/file-max section of proc(5)
for details).
Post by S.K.R. de Jong
3. Does the limit established as above override the ulimit values?
No. And, you really mean getrlimit(2)/setrlimit(2)/sysconf(3), as ulimit(3)
is obsolete.
--
Lew Pitcher
"In Skills, We Trust"
Lew Pitcher
2020-04-12 00:12:00 UTC
Permalink
Post by Lew Pitcher
Post by S.K.R. de Jong
I would like to be able to increase the maximum number of open
files in Slackware. After doing some googling, it would seem that one has
echo 20000000 > /proc/sys/fs/file-max
Note, you can edit your /etc/sysctl.conf to include a line
fs.file-max = 20000000
and /etc/rc.d/rc.S will apply your file-max change automagically on every
reboot.
Post by Lew Pitcher
Post by S.K.R. de Jong
1. Must the system be rebooted, or does the new limit apply
immediately?
It seems unlikely that you would have to reboot the system after applying
a change to /proc/sys/fs/file-max (or any other /proc file), as /proc
files /only/ exist in a running system and a reboot would discard anything
that you write into those files.
Post by S.K.R. de Jong
2. Does the new limit apply immediately to already running
processes, or must such processes be relaunched for the new limit to
become current?
The new limit applies immediately. /BUT/, fs/file-max is /NOT/ a
per-process limit (for that, you want to look at something else, like
setrlimit() ); fs/file-max governs the total number of open files
system-wide (the sum of all files opened by all processes). /AND/, it has
an upper limit set by the kernel constant NR_OPEN. (See the
/proc/sys/fs/file-max section of proc(5) for details).
Post by S.K.R. de Jong
3. Does the limit established as above override the ulimit values?
No. And, you really mean getrlimit(2)/setrlimit(2)/sysconf(3), as
ulimit(3) is obsolete.
--
Lew Pitcher
"In Skills, We Trust"
Henrik Carlqvist
2020-04-12 09:42:02 UTC
Permalink
Post by Lew Pitcher
I would like to be able to increase the maximum number of open files in
Slackware. After doing some googling, it would seem that one has to do
echo 20000000 > /proc/sys/fs/file-max
The new limit applies immediately. /BUT/, fs/file-max is /NOT/ a
per-process limit (for that, you want to look at something else, like
setrlimit() ); fs/file-max governs the total number of open files
system-wide (the sum of all files opened by all processes). /AND/, it
has an upper limit set by the kernel constant NR_OPEN. (See the
/proc/sys/fs/file-max section of proc(5) for details).
3. Does the limit established as above override the ulimit values?
No. And, you really mean getrlimit(2)/setrlimit(2)/sysconf(3), as
ulimit(3) is obsolete.
If you want to increase the per process limit of file descriptors the
place to look is the man page of initscript which has an example of how
to edit /etc/initscript to increase the hard limit of number of open file
descriptors to allow unprivileged processes to by themselves increase
their soft limits. Even though the api ulimit(3) is obsolete the builtin
command in bash to increase the soft limit is still called "ulimit", if
you instead use tcsh the built in command is called "limit". To see how
to edit the initscript file to increase both the hard and the default
soft limit you will need to read up on ulimit in the man page of bash.

But I would say that it is probably a good idea to reconsider the design
if you are designing a system to have millons of simultaneously open file
descriptors.

regards Henrik

Loading...