max file descriptors

sage (sage@newdream.net)
Mon, 05 Jan 1998 21:13:59 -0800


Heya,

I've been been having a rather obnoxious problem with "cannot spawn
child process" errors in my apache logs (1.2.4 and 1.2.0) (around 20,000
- 50,000 a day). Since I have MaxClients, MinSpareServers and
MaxSpareServers set at rediculously high values, I'm pretty sure the
kernel is to blame.

I've tried adjusting the file-max and inode-max at runtime (which at
least two documents I found recommended) like so:

echo 4096 > /proc/sys/kernel/file-max
echo 12288 > /proc/sys/kernel/inode-max

without luck. I also tried

echo 300 400 500 > /proc/sys/vm/freepages

which the kernel HOWTO suggested, although it was unclear what exactly
this is supposed to do.

I also played around with the values in include/linux/fs.h and limits.h
in the 2.0.33 and 2.0.30 kernels with some random results. I finally
got a kernel working with the following values

limits.h:
#define NR_OPEN 1024 /* 256*/
#define OPEN_MAX 1024 /* 256*/ /* # open files a process may
have */

fs.h:
#define NR_OPEN 1024 /*256*/
#define NR_INODE 65536 /*3072*/ /* this should be bigger than NR_FILE */
#define NR_FILE 16384 /*1024*/ /* this can well be larger on a larger
system */

I still experienced (am experiencing) the same problems with apache.
Increasing NR_OPEN and OPEN_MAX to 4096 or higher seemed to prevent the
kernel from booting on both machines I tried it on (it would freeze
right after adding swap). The comments in the headers weren't very
clearn about what NR_OPEN and OPEN_MAX are exactly (and how they
differ).

If anyone has any ideas why apache might still be misbehaving or if I'm
overlooking something else I need to do to increase the effective
maximum number of file descriptors, I'd be much obliged.. the Apache
documentation said that the 'cannot spawn child process' is generally
related to a shortages of file descriptors, so I assumed that was my
problem. If anyone has any other ideas, please let me know. The server
is doing primarily CGI (perl), if that any help.

Also, if someone could shed some light on what OPEN_MAX and NR_OPEN
control and how they differ, that would be helpful as well.

thanks--
sage