httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Goyard <charles.goy...@orange-ftgroup.com>
Subject [users@httpd] Running out of file descriptors with RewriteMap prg
Date Mon, 21 Jan 2008 18:29:00 GMT
Hi dear colisters,

I'm new to the list, so let me introduce myself. My name's Charles, I
work as a product engineer for a major French mobile phone carrier. I'm
a big fan of free software and appreciate Apache much.

Now, here's my problem.

We built a reverse proxy with Apache 2.0 in order to map urls like
"http://example.com/blog/jdoe" to
http://blog.example.com/blog?user=jdoe.  Nothing to worry about.

However, we needed to have sticky sessions by source IP. Basically, I
wrote a small "lb_sh" that returns the IP of the backend server computed
from REMOTE_ADDR. This program is spawned from a RewriteMap directive.

The problem I have is that Apache starts an instance of the program for
each virtualhost. I have 6 different loadbalancers, so each VH adds 6
processes. This is fine and works well. The problem comes from the fact
Apache opens two more additionnal file descriptors for the external
programs.

Here's an example with two vhosts and 3 external programs :

main server -- lb_sh1 = 3 file descriptors (stdin, stdout, stderr)
main server -- lb_sh2 = 5 file descriptors
main server -- lb_sh3 = 7 file descriptors
vhost1      -- lb_sh1 = 10 file descriptors
vhost1      -- lb_sh2 = 13 file descriptors
vhost1      -- lb_sh3 = 15 file descriptors
vhost2      -- lb_sh1 = 18 file descriptors
vhost2      -- lb_sh2 = 21 file descriptors
vhost2      -- lb_sh3 = 24 file descriptors

So it sums up to 117 file descriptors.

Now, I have 85 vhosts and 6 externals. I hitted the default "max open
files" of 1024 and Apache failed to start. My current workaround is to
increase "ulimit -c".

It looks like this from /proc/<pid>/fd/ on Linux 2.6:
lr-x------ 1 root root 64 2008-01-21 19:19 0 -> pipe:[567231]
l-wx------ 1 root root 64 2008-01-21 19:19 1 -> pipe:[567232]
lr-x------ 1 root root 64 2008-01-21 19:19 10 -> pipe:[567224]
l-wx------ 1 root root 64 2008-01-21 19:19 11 -> pipe:[567229]
lr-x------ 1 root root 64 2008-01-21 19:19 12 -> pipe:[567230]
l-wx------ 1 root root 64 2008-01-21 19:19 2 -> /var/log/httpd/error_log
l-wx------ 1 root root 64 2008-01-21 19:19 7 -> pipe:[567221]
lr-x------ 1 root root 64 2008-01-21 19:19 8 -> pipe:[567222]
l-wx------ 1 root root 64 2008-01-21 19:19 9 -> pipe:[567223]
(etc...)

I reduced the external program down to the example found in mod_rewrite
documentation, and Apache's config is real small. Here it is :

ServerRoot  /mnt/httpd
LockFile    var/httpd.lock
PidFile     var/httpd.pid

User  httpd
Group httpd

Listen *:80

RewriteEngine On
RewriteLock var/lbsync.lock
RewriteMap pool1 prg:/mnt/httpd/lib/lb_1
RewriteMap pool2 prg:/mnt/httpd/lib/lb_2
RewriteMap pool3 prg:/mnt/httpd/lib/lb_3

<VirtualHost *>
        ServerName      www.try1.com
        RewriteEngine On
        RewriteOptions inherit
</VirtualHost>
<VirtualHost *>
        ServerName      www.try2.com
        RewriteEngine On
        RewriteOptions inherit
</VirtualHost>
<VirtualHost *>
        ServerName      www.try3.com
        RewriteEngine On
        RewriteOptions inherit
</VirtualHost>


I tried with Apache 2.0.61 and 2.2.8. While 2.2 behaves a lot better (it
does not duplicate useless processes), it still adds the file
descriptors to each new instance.

I may add the RewriteLock does not get created but seems to be handled
within a shm.


Has someone encoutered such a situation ? Is it a misconfiguration, a
bug in Apache, glibc, or in Linux ?


Regards,

-- 
Charles Goyard - charles.goyard@orange-ftgroup.com - (+33) 1 45 38 01 31
Orange Business Services - online multimedia  // ingénierie

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message