Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What's the maximum number of file descriptors that a process can get on OpenBSD successfully?

For example, there is an openfiles limit in login.conf(5) in OpenBSD. If I want to have as many file descriptors as possible, but still don't let a runaway process to bog down the system, what would be a sensible value to set?

E.g. if I specify, say, 20000, will the kernel be capable of giving my application all of these 20000 FDs? What if I'm running multiple instances of a given application (e.g. multiple worker processes)?

share|improve this question

2 Answers 2

There's a good chance that the default values are already set to reasonable values that will support most if not all use cases, they would be based on values found to be needed by running systems used by the OpenBSD developers and admins over the years of development and usage. I believe any limits would be programatically enforced and only truly limited by available resources.

On FreeBSD we have sysctl values for kern.maxfiles and kern.maxfilesperproc - I expect OpenBSD to have the same. Current default limits are much higher than they were just a few years ago as most systems now have enough resources that we don't have a need to limit them.

On my desktop machine I have maxfilesperproc at the default 18000 - I am running xfce4 with chrome, liferea, blender, gimp, text editors and terminals running - ps shows 215 processes and kern.openfiles is at 2683

If you get errors from too many open files then increase them but I doubt you would need to and I doubt you will overload your system by increasing them too high.

share|improve this answer

Taking a look at the source code, to get the default value of max open files:

Well documented code

extern int maxfiles;                 /* kernel limit on number of open files */

maxfiles, on param.c defines the formula to maxfiles

int maxfiles = 5 * (NPROCESS + MAXUSERS) + 80;

OK, we found it.

NPROCESS =

#define NPROCESS (30 + 16 * MAXUSERS)

MAXUSERS = - Lets take amd64 architecture as an example:

machine         amd64
include         "../../../conf/GENERIC"
maxusers        80                      # estimated number of users

Lets sum all the stuff:

maxfiles = 5 * ((30 + 16 * 80) + 80) + 80
maxfiles = 5 * ((30 + 1280) + 80) + 80
maxfiles = 5 * (1390) + 80
maxfiles = 6950 + 80
maxfiles = 7030

I just dont know if you can increase maxusers through config to directly affect your maxfiles, of if you need to change the GENERIC, and recompile your kernel.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.