You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Rodrigo Campos <ro...@geekbunker.org> on 2002/08/29 16:53:40 UTC

[users@httpd] TIME_WAIT and mod_rewrite

I am experiencing a very odd problem with mod_rewrite. This is my scenario:

I have created a couple of rewrite rules and conditions in order to serve
content based on the HTTP_REFERER field, I use an external lookup program
that searches in a database a corresponding match for the HTTP_REFERER, and
returns the directory where the correct images shold be read by the apache
server.

So I have:

###
RewriteLog      /usr/local/apache/logs/rewrite_log
RewriteLogLevel 0
RewriteMap     referermap      prg:/usr/local/bin/ap_lookup
RewriteLock     /usr/local/apache/logs/rewrite.lck
RewriteEngine on

RewriteCond     %{HTTP_REFERER}         ^https?://(.{1,255}).*$ [NC,OR]
RewriteCond     %{HTTP_REFERER}         =""
RewriteRule     ^/([^/]*\.(gif|map))
/foo/bar${referermap:%1|/default}/$1 [L,NC]
###

The problem is that the external lookup program is called even when I have
no referer at all, which is useless since it will always return 'NULL' and
the '/default' directory will be used.

In order to solve this undesired behaviour, I've changed the rewrite rules
in the following way:


###
RewriteCond     %{HTTP_REFERER}         ^https?://(.{1,255}).*$ [NC]
RewriteRule     ^/([^/]*\.(gif|map))
/foo/bar${referermap:%1|/default}/$1 [L,NC]

RewriteCond     %{HTTP_REFERER}         =""
RewriteRule     ^/([^/]*\.(gif|map))      /foo/bar/default/$1 [L,NC]
###

Everything works just fine, but the TIME_WAIT count *and* the traffic has
almost doubled (!). Actually I have two identical machines, each one is
running one of the rewrite rule set, and the results are the following
(bubble1 has only one rewritecond, and bubble2 has two rewriteconds):

[lardossan@bubble1 ~]$ netstat -na | grep TIME_WAIT | wc -l
    917

[lardossan@bubble2 ~]$ netstat -na | grep TIME_WAIT | wc -l
    1548

I am not really worried about the TIME_WAIT count, since it's far from the
current limit, but the extra traffic is really weird:

Traffic for bubble1:

07:41:01 AM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s
txcmp/s  rxmcst/s
07:51:01 AM      eth2     67.08     63.66   9690.78  17077.29      0.00
0.00      0.00
08:01:00 AM      eth2     77.64     73.72  11287.47  19552.00      0.00
0.00      0.00
08:11:00 AM      eth2     89.55     84.97  13067.28  22809.18      0.00
0.00      0.00
08:21:00 AM      eth2    103.21     97.61  14982.88  26332.01      0.00
0.00      0.00
08:31:00 AM      eth2    109.82    104.62  16053.41  28012.65      0.00
0.00      0.00
08:41:00 AM      eth2    112.61    107.22  16384.71  28353.04      0.00
0.00      0.00
08:51:00 AM      eth2    116.78    110.64  16975.49  29406.99      0.00
0.00      0.00
09:01:00 AM      eth2    119.45    113.36  17507.21  29883.50      0.00
0.00      0.00
09:11:00 AM      eth2    121.80    115.49  17852.66  30853.61      0.00
0.00      0.00
09:21:00 AM      eth2    123.95    117.64  18048.68  30932.73      0.00
0.00      0.00
09:31:00 AM      eth2    129.15    122.81  18932.81  32221.79      0.00
0.00      0.00
09:41:00 AM      eth2    128.48    121.69  18741.77  31991.27      0.00
0.00      0.00
09:51:00 AM      eth2    129.03    122.22  18904.32  31604.59      0.00
0.00      0.00
10:01:00 AM      eth2    129.20    123.03  18927.98  32220.68      0.00
0.00      0.00


Traffic for bubble2:

07:41:00 AM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s
txcmp/s  rxmcst/s
07:51:00 AM      eth2    110.62    107.35  15235.60  35922.16      0.00
0.00      0.00
08:01:00 AM      eth2    128.64    125.45  17813.91  42085.30      0.00
0.00      0.00
08:11:00 AM      eth2    147.42    143.38  20564.22  48255.24      0.00
0.00      0.00
08:21:00 AM      eth2    174.16    169.37  24264.90  57385.08      0.00
0.00      0.00
08:31:00 AM      eth2    183.53    178.64  25697.69  60661.71      0.00
0.00      0.00
08:41:00 AM      eth2    187.63    182.68  26141.47  61497.02      0.00
0.00      0.00
08:51:00 AM      eth2    196.34    191.07  27423.06  64971.34      0.00
0.00      0.00
09:01:01 AM      eth2    203.40    199.39  28499.96  67936.44      0.00
0.00      0.00
09:11:01 AM      eth2    207.75    202.82  29171.18  69188.77      0.00
0.00      0.00
09:21:01 AM      eth2    199.95    195.40  28064.81  66504.47      0.00
0.00      0.00
09:31:01 AM      eth2    211.22    206.43  29582.79  70104.32      0.00
0.00      0.00
09:41:01 AM      eth2    209.74    204.72  29422.39  69196.74      0.00
0.00      0.00
09:51:01 AM      eth2    209.66    204.99  29413.19  69838.16      0.00
0.00      0.00
10:01:00 AM      eth2    215.39    210.15  30272.52  71425.53      0.00
0.00      0.00


There's a very small increase in the server load, that I believe is normal
due to the fact that there are more rules to be processes and regular
expressions to be compiled.

The system is a Red Hat Linux with 2 processors and 1Gb RAM:

Linux bubblex 2.4.18 #1 SMP Fri Jun 21 20:41:50 GMT-3 2002 i686 unknown

Apache is:

Server version: Apache/1.3.26 (Unix)
Server built:   Jun 20 2002 20:10:12

I had the same results running on Solaris 7 for Sparc, so I really do not
believe that this is an OS related problem.

Some parameters from httpd.conf are:

Timeout 5
KeepAlive Off
MaxKeepAliveRequests 0
KeepAliveTimeout 0
MinSpareServers 128
MaxSpareServers 256
StartServers 768
MaxClients 3000
MaxRequestsPerChild 0

I've digged into the mailing lists and found no related problem, do you guys
have any ideas ?

Thank's in advance,

--
Rodrigo Albani de Campos
http://geekbunker.org/rodrigo/?sig

Eat Healthy
Stay Fit
Die Anyway


---------------------------------------------------------------------
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