The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FIX: Apache error - "Too many open files"

Discussion in 'EasyApache' started by Echelon17, Jun 17, 2006.

  1. Echelon17

    Echelon17 Well-Known Member

    Joined:
    May 21, 2006
    Messages:
    72
    Likes Received:
    0
    Trophy Points:
    6
    OK, our high load server went down this evening and Apache was spitting out these "Too many open file" error messages. Then asking me to increase the file descriptors.

    Note: We have over 7000 virtualhosts on this server, so that's a lot of logfiles open! Before anyone says i'm crazy, I'm not. The server load is absolutely fine and it's not even breaking a sweat. IO times are fine also.

    Some background on this issue:
    Cpanel do their whole statistics package the WRONG WAY. They log to numerous files simultaneously and as a result tons and tons of files are opened simultaneously also. Apache actually recommend that on high load servers you log everything to a single file, and then run their split-logfile utility to seperate the combined log into individual domain logs. You can then process these files with webalizer or any other statistics package accordingly. This keeps your number of open files down and everything running happily. I submitted this as a question to CPanel and as of yet have had no response. Typical.

    So anyway, after spending several hours trawling the internet looking for a solution to this problem, I managed to resolve it using a couple of different suggested methods thrown together. It seems that Apache takes it's hardcoded descriptor limit from system files, and the only way to resolve the issue is to recompile.

    Modify these 2 files:

    /usr/include/bits/typesizes.h
    /usr/include/linux/posix_types.h

    Find the value for FD_SETSIZE and increase it. I doubled this value, just to keep things simple. Do it for both files. Save files.

    Next, login to WHM and select 'Apache Update'. UNTICK "Raise FD_SETSIZE to 16384 (System Wide)" and then select all relevant modules/options that you need for installation. Compile Apache and your problem should be solved.

    So far things are now working fine for us, though Apache has over half a million open files it's still running ok.
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Isn't that what /etc/init.d/filelimits is for? To do it dynamically.
     
  3. Echelon17

    Echelon17 Well-Known Member

    Joined:
    May 21, 2006
    Messages:
    72
    Likes Received:
    0
    Trophy Points:
    6
    Dynamically is no good when you need to reboot your box though. A permanent solution is needed.
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Ah, but /etc/init.d/filelimits does store the latest value and reapplies it on boot.
     
  5. Echelon17

    Echelon17 Well-Known Member

    Joined:
    May 21, 2006
    Messages:
    72
    Likes Received:
    0
    Trophy Points:
    6
    Ah yeah of course, because it runs on startup - my bad, sleep deprivation ;)

    However I'm not sure, but I've read that Apache's FD limit is hard-coded through the use of the 2 files mentioned previously, so you need to modify and then recompile afterwards.

    Unfortunately i'm not in the position to test it anymore, so can't verify.
     
  6. web12

    web12 Well-Known Member

    Joined:
    Nov 20, 2002
    Messages:
    240
    Likes Received:
    0
    Trophy Points:
    16
    Hi Guys

    Hope you dont mind me bringing back an old thread, but I have a similar issue and this fix doesnt cure it.

    A client of mine with his own dedi has hundreds of subdomains. It seems we have hit a limit as httpd crashes and gives the following error:-

    If I swap in a copy of httpd.conf from a day before which doesnt have the last few subdomains added in it, apache restarts perfectly fine.

    Am i right in thinking that this is because of the amount of logs it has created? If so would it not make sense to just create 1 log for all the subdomains in this instance? I dont even think the logs are needed in this cirumstance... its purely for seo purposes.

    Any advice you can give would be welcome.
     
Loading...

Share This Page