[prev in list] [next in list] [prev in thread] [next in thread] 

List:       inet-access
Subject:    Re: Apache config question.
From:       "james" <hackerwacker () cybermesa ! com>
Date:       2004-01-23 18:19:53
Message-ID: 007001c3e1dd$7f6c93b0$0200020a () jamesnew
[Download RAW message or body]

 (24)Too many open files: couldn't spawn child process:
: 

I have seen this. The max # of open files is a kernel value.
We configed too many domains on a web server, as each opens 
2 log files. 512 domains was a soft limit and we could start apache 
with a script that upped this limit to a max. 

The quick hack is to use a script like this:

#!/bin/sh
unlimit
/usr/local/apache2/bin/apachectl start


Here are my notes, this is specific to BSDi howerer:

The problem you're experiencing is due to the number of active domains, each
being configured with their own access and error log files.

When Apache starts up, it opens or creates two log files for each domain in
/var/log/httpd/{domain}/ in addition to the "main" server log files in
/usr/local/apache2/logs/. This is by configuration. The system kernel limits
the number of open files on a per-process basis to 1024 and sets this
structure in the system header files as FD_SETSIZE.

If you want to keep per-domain logging, there are at least two possible
fixes and given a little more time I may be able to find more.

The first fix is to setup a second installation or configuration of apache.
It is fairly easy to write startup scripts for running two Apache instances
using the same executables (simplifying patches and upgrades). The maximum
number of domains per installation/configuration would be 1024/2-2 (510).
Each configuration would require a unique IP address. The difficulty would
be reorganizing the DNS for each virtual host and keeping the correct zone
pointed at the correct IP address. I can make several suggestions regarding
this and write some minimal tools to assist with creating/deleting/synching
zones between the nameserver and the Web server.

The second fix is to rebuild the kernel with a new FD_SETSIZE and recompile
Apache and all related utilities and libraries, possibly including libc. The
maximum number of file handles is determined by kernel process structures
and it is possible to increase this value. It should be a configuration
option in /usr/src/sys/i386/conf (maybe "options FD_SETSIZE xxxx"). This
isn't a preferred option, but if you have automated utilities that depend on
the location and style of the Apache configuration it may be easier to
rebuild the necessary system files than to rebuild automated configuration
tools. Although I'm very familiar with FreeBSD and Linux, I don't feel
comfortable doing this on a BSD/OS system. I would suggest for you to
consult with your BSD vendor before doing this because it very well could
break some other dependencies.

Later, after I had read some more:

This link describes _exactly_ what your issue is:

http://httpd.apache.org/docs-2.0/vhosts/fd-limits.html

and a possible _easy_ solution:

http://httpd.apache.org/docs-2.0/misc/descriptors.html

which basically says you may not requre a kernel rebuild (although your
current limit on the number of open files across the entire system is 6668,
you may want to rebuild with a high value for "maxusers" or manually set
"maxfiles" in your kernel config to give you at least 16k available file
handles).

>From everything I've read in the last couple of hours, your kernel has the
same configuration as the later FreeBSD kernels. You shouldn't have any
problems with system libraries or utilities when changing the maximum number
of file handles as this was moved out of the process structure (older BSD
kernels would require a rebuild of `ps` and `top` or they would spit out
garbage and kill would mysteriously stop working sometimes).

So, I would estimate a good place to start with "maxusers" is 256. The magic
number "0" currently makes 1 user per MB of RAM. The calculations for the
maximum number of system processes and open files are performed in
/usr/src/sys/conf/params.c. You may be able to add a configuration option,
"maxfiles" and set it to something high like 16384 (or some other x^2
value).

Rebuild Apache by adding the -DFD_SETSIZE=2048 (or higher) option to Apache
as described in the second link above and you should be all good to go.






_______________________________________________
"Eat sushi frequently". - Avi
inet@inet-access.net is the human contact address.
list@inet-access.net is the list posting address.
See below URL for subscribe/unsubscribe and list options:
http://inet-access.net/mailman/listinfo/list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic