file descriptors

floyd

Verified User
Joined
Mar 29, 2005
Messages
6,248
I built a super server to handle a bunch of users and domains. But now apache doesn't want to open all the files needed. I get:

Code:
[warn] (24)Too many open files: unable to open a file descriptor above 15, you may need to increase the number of descriptors

I have tried every suggestion I could find on Google. Is this possibly an Apache 1.3 limit and would upgrading to Apache 2 help or is it possibly a kernel limit?

I tried increasing the limit in the limits.conf file and also sysctl.conf file.
 
Here are some notes from my collection of same:
Possible Causes of apache not running with two many domains:
1) MaxClients set to a value too low
2) If you have over about 800 sites, the ErrorLog files open
too many file descriptors and apache won't be able to log
the errors and may stop responding.

Solutions:
1) edit /etc/httpd/conf/httpd.conf and increase the MaxClients
setting to something like 200 or 300.
2)
cd /usr/local/directadmin/data/templates
cp virtual_host*.conf custom
cd custom
# remove all the ErrorLog lines (or comment them out)
from the 4 virtual_host*.conf files that are in the custom directory.

echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
Apache should be restarted automatically after a few minutes later
(rewrite might take a while with over 800 sites).

Other possible information:
Edit /usr/include/bits/typesizes.h and set
#define __FD_SETSIZE 32768
and then recompile using custombuild or customapache
Jeff
 
Thanks Jeff. I think I need to edit typesizes.h.

Currently I have

Code:
#define __FD_SETSIZE 32768

Do I need to uncomment that line (if indeed it is a comment) or just set the number higher?
 
If you're changing it you should uncomment it.

(If I recall correctly)

Jeff
 
Thanks. Can you explain why for those of us who don't do too much building?

Thanks.

Jeff
 
"#define is a useful C component that allows you to give a name to a constant value before the program is compiled. The compiler will replace references to these constants with the defined value at compile time."

The # is necessary.
 
Somehow I got it working. If I can ever figure out all the things I tried and extract the ones that were necessary I will post a howto.

But one big thing that got me was the startup script for httpd has 4 ulimit lines.

Code:
        ulimit -n 2048
        ulimit -n 4096
        ulimit -n 8192
        ulimit -n 16384

So even though I was increasing the limit elsewhere every time I restarted httpd it would decrease it to 16384 (I think). So I added another line after that

Code:
ulimit -n 131072

I am always scared to mess with stuff on a production server so I did not delete the previous lines. But it does make me wonder why the default has 4 ulimit lines. Doesn't make sense to me.
 
Back
Top