Re: What is the best way to handle "too many open files" errors?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just had something of a "slap your forehead" moment on this one. It had be eating me about where all those extra lsof processes came from. And then it hit me. It's the "developer tools" kit from CentOS. Duh.

http://www.linuxtopia.org/online_books/centos_linux_guides/centos_linux_developer_tools_guide/

Any tips for the smartest way to pull it apart after the fact?

On Thu, May 21, 2009 at 5:55 PM, Sean Conner <spc@xxxxxxxxxx> wrote:
It was thus said that the Great Mick Sheppard once stated:
> Hi,
>
> Just to throw a slight spanner in the works here. My understanding of
> 'open files' is open file descriptors. As far as a file descriptor is
> concerned there is no real difference between a physical file on disk
> and a socket (network connection). So eliminating physical files, whilst
> it might get you a little more headroom, is unlikely to solve the
> problem.

 Yes and no.  Yes, sockets are considered "opened files" and do count
against the open file limit, that limit is *per process*, not *system wide*.
I just checked one of our main web servers (serving up a few hundred sites)
and found only three active sockets per process:

       1. the listening socket on port 80, waiting for a connection
       2. the listening socket on port 443, waiting for a connection
       3. an actual connection to a client

 The main root process only has the first two sockets open.  If you have
Apache configured to have at a minimum 30 spare servers, no one Apache
process will have 30 sockets open---sockets just don't work that way.  What
it does mean is you have at least 31 apache processes running, one as root
(to bind to the proper ports [1]) and 30 ready to service a request, so at
most, any Apache process will have one socket per Listen statement, and one
socket only when actually processing a request.

 So, for example, let's say you have the following Apache configuration:

Listen                  *:80
StartServers             100
MinSpareServers          100
MaxSpareServers          900
ServerLimit             1000
MaxClients              1000
MaxRequestsPerChild     4000
CustomLog               access_log
ErrorLog                error_log

All your apache processes would have only seven files open (eight if serving
a request), and they would look something like:

       0       -> /dev/null    (STDIN)
       1       -> /dev/null    (STDOUT)
       2       -> error_log    (STDERR)
       3       -> listening socket
       4       -> pipe (for CGI communications)
       5       -> pipe (for CGI communications)
       6       -> error_log
       7       -> access_log

 The real concern are log files, not the number of connections in the
Apache configuration.  The only way the number of connections might be a
consideration is if you are using the threading MPM, where each thread (in a
single process) gets a connection.

> Remember that as you add connectivity to databases that this will
> increase the number of sockets, and therefore open files, used for each
> page served.

 True, but you really need to look at this at the process level.

 -spc

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux