WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to increase the max # of open file descriptors?  (Read 9145 times)

Offline qopit

  • Jr. Member
  • **
  • Posts: 81
How to increase the max # of open file descriptors?
« on: May 02, 2012, 01:00:59 PM »
How do you increase the hard limit on the maximum number of open file descriptors in Core?  Right now the hard limit is 4096 for me.  Where is this being set?

On other systems I've been able to adjust /etc/security/limits.conf, but that seems to be a "pam" thing, which is not in use with Core, and I don't see a pam extension (nor am I sure I want one).

With ulimit being a shell thing, I've been looking into busybox, but no luck so far.  Same goes for pam, which is a new thing for me.

Code: [Select]
tc@box:~$ cat /proc/sys/fs/file-max
50644
tc@box:~$ ulimit -Hn
4096
tc@box:~$ ulimit -Sn 4096
tc@box:~$ ulimit -n
4096

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11098
Re: How to increase the max # of open file descriptors?
« Reply #1 on: May 02, 2012, 01:17:31 PM »
No support for a limits file in busybox, based on a quick look. The 4096 is a linux default, likely.

Only root can raise the limits, so if you need higher, set them as root and then switch user (su tc).
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12684
Re: How to increase the max # of open file descriptors?
« Reply #2 on: May 02, 2012, 01:47:20 PM »
Hi qopit
Don't know if this helps, but there is an extension called   Linux-PAM.tcz   and under the  Files  tab in AppBrowser it lists:
Quote
usr/local/etc/security/limits.conf

Offline qopit

  • Jr. Member
  • **
  • Posts: 81
Re: How to increase the max # of open file descriptors?
« Reply #3 on: May 03, 2012, 01:58:57 AM »
Curaga: thanks!  I hadn't considered that root could change the hard limits and they would stick on an su.  Even the soft limit/setpoint carries through...

Code: [Select]
tc@box:~$ ulimit -Hn
4096
tc@box:~$ sudo su
root@box:~# ulimit -Hn 10000
root@box:~# ulimit -Sn 10000
root@box:~# su tc
tc@box:~$ ulimit -Sn
10000

For anyone else looking for this, this is very convenient for adding to bootlocal.sh (which runs with root privs) to run an application with more than 4096 possible open file descriptors.  Something like this works perfectly:

Code: [Select]
ulimit -Hn 65535
ulimit -Sn 65535
su -c "some_program" tc

Also, Rich: thanks for the PAM link... I feel like an idiot not finding it. :(

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12684
Re: How to increase the max # of open file descriptors?
« Reply #4 on: May 03, 2012, 02:19:37 AM »
Hi qopit
Changing the Search option to Provides in AppBrowser and entering  pam  in the search field finds it quickly.

Offline qopit

  • Jr. Member
  • **
  • Posts: 81
Re: How to increase the max # of open file descriptors?
« Reply #5 on: May 03, 2012, 09:11:58 AM »
Rich: Big thanks for that, too... I didn't know ab had that "Provides" option either.  Now that I see provides.sh behind it, I'll definitely be using that more!

This is probably a consequence of me never using anything other than MicroCore/Core... I expect that the existence of the "provides" option is more prominent in the GUI version.  That's my excuse and I'm sticking to it.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1832
Re: How to increase the max # of open file descriptors?
« Reply #6 on: Today at 08:44:28 AM »
I realize this thread is 14 years old, but it was useful to me today! I have something to add:

My server is powered by TCL. I run galene videoconference server on it (https://galene.org/galene-install.html), among many other things. Galene needs a high file descriptor limit in order to work well.

qopit's advice here works:
Code: [Select]
tc@box:~$ sudo su
root@box:~# ulimit -Hn 65536
root@box:~# ulimit -Sn 65536
root@box:~# su tc
tc@box:~$ ulimit -Sn
65536
tc@box:~$ galene &
But I found the method above to be impossible to put in a shell script (a script that, for example, restarts the galene server after my ssl certificate has been renewed). The fact that ulimit is a shell builtin really complicates things.

The solution for me was to use prlimit (provided by util-linux.tcz), which is just a regular executable at /usr/local/bin/prlimit.

Here is the script I run to restart galene after my ssl certificate has changed due to renewal. I called it videoconference-restart.sh:

Code: [Select]
#!/bin/sh
pkill galene
galene &
galene_pid=$!
sudo prlimit --pid=$galene_pid --nofile=65536
Other users with special need for high file descriptor limit, who are struggling with ulimit, may also find prlimit to be useful.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1832
Re: How to increase the max # of open file descriptors?
« Reply #7 on: Today at 01:42:08 PM »
Alternative to using ulimit, short version:
Code: [Select]
$ tce-load -wi util-linux
$ your-nice-app &
$ sudo prlimit --pid=$! --nofile=65536
I'm not sure whether child processes of your nice app would inherit the higher file descriptor limit. My guess is no. That may be a caveat.
« Last Edit: Today at 01:44:22 PM by GNUser »