Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jan 1997 04:02:38 +1100
From:      davidn@unique.usn.blaze.net.au (David Nugent)
To:        fbsdlist@revelstone.jvm.com (Cliff Addy)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Setting maximum number of files
Message-ID:  <Mutt.19970116040238.davidn@labs.blaze.net.au>
In-Reply-To: <Pine.BSF.3.91.970114124725.16708A-100000@revelstone.jvm.com>; from Cliff Addy on Jan 14, 1997 13:18:40 -0500
References:  <Pine.BSF.3.91.970114124725.16708A-100000@revelstone.jvm.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Cliff Addy writes:
> I'm running into a problem running an Apache server under 2.1.5, it 
> appears that I'm running into a file limit.  I've rebuilt the kernel once 
> before, upping maxusers,  CHILD_MAX, and OPEN_MAX to 256 each.  If I do a 
> limit under the root shell, I get 
> 
> descriptors     256

That should be plenty.

You could find out for sure using lsof (in ports), which lists
- probably in a lot more detail than you need :-) - all of the
open files in the system. It is useful for diagnosing these
sorts of problems.


> which I presume means file descriptors.  If I invoke the server, it dies 
> with (I beleive) a signal 11.  If I remove a virtual host, which drops 
> the number of files opened, it runs fine.

What you need to do is attach gdb to the process before it
crashes, then find out where and why it crashes. Out of file
handles would not normally do this unless something were very
poorly coded indeed.

I should warn you that there *is* a bug in apache 1.1.1 which is
related to virtual hosts. If you have a virtual host entry by
ip number, i.e.

<VirtualHost 1.2.3.4>
...
</VirtualHost>

and the IP isn't in the DNS, then apache will crash each and
every time it gets to that entry when scanning through to find
out which host a connection is for, due to a null pointer
dereference (on the hostname field, as it turns out). The bug
may also be triggered if an fdqn is not available in the DNS
too - my memory of the code fixed at the time I found it was
that this also would have problems.

This may have been fixed in the 1.1.2 "security" fix recently
as I reported the problem, which included a patch, a few weeks
ago. If not, I can probably dig up the patch.


> a)  Am I really seeing a file descriptor problem?  There are
> no messages logged, which I beleive I got before.

It is almost impossible to determine this except by using
the debugger to find out precisely why it crashes.


> b)  Why does changing the limit have no effect?

Maybe because that isn't the problem. :-) To be honest, I
seriously doubt that it is a descriptor limits problem.


> c)  How can I invoke the server to have maximum limits without actually 
> typing it?  Would it be as simple as a limit command in rc.local (which 
> actually starts the server)?  Or do I need to wrap the command in a shell 
> script that uses csh or tcsh?

sh can do this just fine. /bin/sh uses a "ulimit" command instead
of a "limit" command. In fact, all popular shells have standard
resource setting commands in one form or another (except perl,
it seems :(). If you want to make more handles available for apache,
then insert the following into /usr/local/etc/rc.d/apache.sh:

#!/bin/sh
ulimit -n unlimited
[ -f /usr ... etc


> d) Is there a limit to the size of maxusers, etc?  Can I, for example, 
> use 2048 for these values?

The limit is dependant on how much memory you have available.
You're probably throwing away a pile of resources in taking it
up that high. One of my clients runs something over 100 vhosts
on a 2.1.5 box, many of the web trees containing literally
thousands of files - we don't have file descriptor problems,
nor have we had do do anything about attempting to up the default
descriptor limits for web server processes. CHILD_MAX and OPEN_MAX
are both set to 64. As you might guess, this is where the "ip not in
DNS" bug was discovered.


Regards,

David Nugent - Unique Computing Pty Ltd - Melbourne, Australia
Voice +61-3-9791-9547  Data/BBS +61-3-9792-3507  3:632/348@fidonet
davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Mutt.19970116040238.davidn>