Return-Path: Delivered-To: apmail-httpd-users-archive@www.apache.org Received: (qmail 9064 invoked from network); 20 May 2009 09:06:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 May 2009 09:06:38 -0000 Received: (qmail 70644 invoked by uid 500); 20 May 2009 09:06:47 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 70616 invoked by uid 500); 20 May 2009 09:06:47 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 70605 invoked by uid 99); 20 May 2009 09:06:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 May 2009 09:06:47 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of icicimov@gmail.com designates 209.85.221.127 as permitted sender) Received: from [209.85.221.127] (HELO mail-qy0-f127.google.com) (209.85.221.127) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 May 2009 09:06:37 +0000 Received: by qyk33 with SMTP id 33so481123qyk.10 for ; Wed, 20 May 2009 02:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=rf0t0zuGKwAekvKeoTJQTtQF3Ge/Hok3Bi085XQu0u8=; b=b9exzT7WsMnTUiI42LJFaEV5+CsQ6RzjJQ/t34vUYvFnh5/uGni7o6mEbTZ12dR7sH weeucI09CzPTy7BslAIGcf61Z1uvifLBIwZivI6iklyQM0ZH1gUzITeeX+QbNOQF9Y2H HCisH61VUfK0l1QUAtFID87kEnxvyh+XdRsV4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=nIh7KdjGfK0liKGhXuEoU6aHsrIz60FIxWX9KxJWZccdmTc7qZsSz9x3kWuKxalIHz O5V9iK6tqOlfleShG2dHKQ9tk6qnpys+YnsDmjJNAK+3XOqeSS+8uDFXJ505g0ek+doK +Lfi2pSm6SbO0rhsFXn2bNPE4xHOgPkGVLdAQ= MIME-Version: 1.0 Received: by 10.220.92.205 with SMTP id s13mr1227354vcm.31.1242810376583; Wed, 20 May 2009 02:06:16 -0700 (PDT) In-Reply-To: References: Date: Wed, 20 May 2009 19:06:16 +1000 Message-ID: From: Igor Cicimov To: users@httpd.apache.org Content-Type: multipart/alternative; boundary=00163631080504fac7046a5457d7 X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [users@httpd] What is the best way to handle "too many open files" errors? --00163631080504fac7046a5457d7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Have you considered increasing the open files limit? Have a look at the ulimit command. The default is sometimes not enough. Cheers, Igor On Wed, May 20, 2009 at 4:00 PM, Ben Welsh wrote: > Hello, > > I'm managing a pgsql --> django --> mod_python --> apache machine that > serves no media, but handles the postgres memcached and apache part of the > stack all by itself. It's a dedicated virtual server with Red Hat EL and 1GB > RAM. > > As traffic to the site has ramped up over time, I've begun to encounter "too > many open files in the system" errors via Apache that look something like > this: > > OperationalError: FATAL: could not open file : Too many open > files in systemThis has become something of a debilitating problem and I'm > struggling to come up with the best strategy for handling it. Some people > have told me that I can solve it by better configuring my existing machine > -- while others have insisted that I must upgrade my server rig by expanding > it beyond one DV. > > My hopes in posting here is that y'all might give me some insight into how > I can answer the question about the better approach. > > I've run the commands you see below and the conclusion that I'm drawing is > that the I simply have way too many httpd file objects open -- but I'm > unsure about the wisest way of reducing them -- or whether I can reasonably > expected them to go down much. > > I'd very much appreciate any insight the list could provide into the > situation, even if it's just point me to a reference. I've trolled the lists > and the web and still am a Iittle unsure of the best approach, so I thought > I'd post. If I'm overlooking the most awesome tutorial or previous lister > post ever, please forgive my ignorance. I'd appreciate even just the link. > > Thank you, > > Ben. > > $ ulimit -a > core file size (blocks, -c) 0 > data seg size (kbytes, -d) unlimited > file size (blocks, -f) unlimited > pending signals (-i) 1024 > max locked memory (kbytes, -l) 32 > max memory size (kbytes, -m) unlimited > open files (-n) 1024 > pipe size (512 bytes, -p) 8 > POSIX message queues (bytes, -q) 819200 > stack size (kbytes, -s) 10240 > cpu time (seconds, -t) unlimited > max user processes (-u) 137215 > virtual memory (kbytes, -v) unlimited > file locks (-x) unlimited > > *postgres*.conf (max_files_per_process is commented out) > max_connections = 100 > shared_buffers = 1000 > > $ httpd -l > > Compiled in modules: > core.c > prefork.c > http_core.c > mod_so.c > > httpd.conf... > > Timeout 20 > KeepAlive Off > MaxKeepAliveRequests 100 > KeepAliveTimeout 5 > > StartServers 8 > MinSpareServers 5 > MaxSpareServers 20 > ServerLimit 256 > MaxClients 256 > MaxRequestsPerChild 4000 > > > $ cat /proc/sys/fs/file-nr > 73320 0 262144 > > $ lsof | awk '{print $1}' | sort | uniq -c > 1 COMMAND > 10 awk > 49 bash > 17 crond > 5154 httpd > 9 init > 25 lsof > 39 memcached > 807 postmaste > 62 saslauthd > 69 sendmail > 28 sh > 7 sort > 183 sshd > 13 syslogd > 8 uniq > 19 xinetd > > --00163631080504fac7046a5457d7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Have you considered increasing the open files limit? Have a look at the uli= mit command. The default is sometimes not enough.

Cheers,

Igo= r

On Wed, May 20, 2009 at 4:00 PM, Ben We= lsh <ben.welsh@= gmail.com> wrote:
Hello,

I'm managing a pgsql --> django --> mod_python --> apache m= achine that serves no media, but handles the postgres memcached and apache = part of the stack all by itself. It's a dedicated virtual server with R= ed Hat EL and 1GB RAM.

As traffic to the site has ramped up over time, I've begun to= encounter
"too many open files in the system" error= s via Apache that look something like this:

OperationalError: FATAL: could not open file <filename&= gt;: Too many open files in system

This has become something of= a debilitating problem and I'm struggling to come up with the best str= ategy for handling it. Some people have told me that I can solve it by bett= er configuring my existing machine -- while others have insisted that I mus= t upgrade my server rig by expanding it beyond one DV.

My hopes in posting here is that y'all might give me some insight i= nto how I can answer the question about the better approach.

I'= ve run the commands you see below and the conclusion that I'm drawing i= s that the I simply have way too many httpd file objects open -- but I'= m unsure about the wisest way of reducing them -- or whether I can reasonab= ly expected them to go down much.

I'd very much appreciate any insight the list could provide into t= he situation, even if it's just point me to a reference. I've troll= ed the lists and the web and still am a Iittle unsure of the best approach,= so I thought I'd post. If I'm overlooking the most awesome tutorial or previous lister post ever, please forgive my ignorance. I'd appreciate even just the link.

Thank you,

Ben.

$= ulimit -a
core file size=A0=A0=A0=A0=A0=A0=A0=A0=A0 (block= s, -c) 0
data seg size=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (kbyte= s, -d) unlimited
file size=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 (blocks, -f) unlimited
pending signals=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (-i) 1024
max locked memory=A0=A0=A0=A0=A0=A0 (kbytes, -l) 32max memory size=A0=A0=A0=A0=A0=A0=A0=A0 (kbytes, -m) unlimited
open files=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 (-n) 1024
pipe size=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (512 bytes, -p) 8 POSIX message queues=A0=A0=A0=A0 (bytes, -q) 819200
stack s= ize=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (kbytes, -s) 10240
cpu time=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (seconds, -t) unlimit= ed

max user processes=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (-u) 137215
virtual memory=A0=A0=A0=A0=A0=A0=A0=A0=A0 (kbytes, -v) unlimited
file locks=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (= -x) unlimited

postgres.conf (max_files_per_proce= ss is commented out)
max_connections =3D 100
shared_buffers =3D 1000


$ httpd -l

Compiled in modules:
=A0 core.c
=A0 prefork.c
=A0 http_core.c
=A0 mod_so.c

httpd.conf...

Timeout 20
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 5

<IfModule prefork.c>
StartServers =A0 =A0 =A0 8
MinSpareServers =A0 =A05
MaxSpareServers =A0 20
ServerLimit =A0 =A0 =A0256
MaxClients =A0 =A0 =A0 256
MaxRequestsPerChild =A04000
</IfModule>

$ cat /proc/sys/fs/file-nr
73320=A0=A0= 0=A0=A0=A0=A0=A0=A0 262144

$ lsof | awk '{print $1= }' | sort | uniq -c
=A0=A0=A0=A0=A0 1 COMMAND=A0=A0=A0=A0 10 awk
=A0=A0=A0=A0 49 bash
=A0=A0=A0=A0 17 crond
= =A0=A0 5154 httpd
=A0=A0=A0=A0=A0 9 init
=A0=A0=A0=A0 25 lsof

=A0=A0=A0=A0 39 memcached
=A0=A0=A0 807 postmaste
=A0=A0=A0=A0 62 saslauthd
=A0=A0=A0=A0 69 sendmail
=A0=A0=A0=A0 28 sh
=A0=A0=A0=A0=A0 7 sort
=A0=A0=A0 183 sshd
=A0=A0=A0=A0 13 syslogd
=A0=A0=A0=A0=A0 8 uniq=
=A0=A0=A0=A0 19 xinetd


--00163631080504fac7046a5457d7--