httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronald Park <r...@cnet.com>
Subject mod_proxy timeouts in the 2.0
Date Tue, 05 Feb 2008 19:52:09 GMT
The problem and patch in the below message are in regards to just
the Apache 2.0 line; it seems like a number of improvements in
timeout handling have already been implemented in the 2.2 version
of mod_proxy.

However, also included in my patch is a mechanism to provide even
more granularity in timeouts by setting it via an environment var:
I have not done the work though to find an implementation in the
2.2 line though but if there is an interest, I could investigate it.

On to my problem and a possible patch:

According to the description of the ProxyTimeout directive, this
is the expected behavior of that directive:

> This directive allows a user to specifiy a timeout on proxy requests.
> This is useful when you have a slow/buggy appserver which hangs, and
> you would rather just return a timeout and fail gracefully instead
> of waiting however long it takes the server to return.

However, this is not what occurs.  The ProxyTimeout is only used
to obtain the connection to the 'origin server'; when it actually
sends the proxied request and waits for the response, the value of
the Timeout directive is used.

Unfortunately, mod_proxy uses a core function called 'pre_connection'
after the connection has been made (despite the 'pre' in the function
name :D) and therein lies the problem.  That code only has access to
the server config, not the modules configs, and it resets the timeout
to the value of the Timeout directive.

My fix is to reset the timeout *after* the call to pre_connection if
this directive is set.

I also added new functionality allowing a special environment
variable ("proxy-timeout") to be set to overload the directive for
more fine-grained control.  This would allow the following:

ProxyTimeout 15

RewriteRule ^/proxy/(.*)$ http://someotherserver.com/$1

RewriteRule ^/quick/(.*)$ http://someotherserver.com/$1 \
                                      [E=proxy-timeout:5]

RewriteRule ^/slow/(.*)$ http://someotherserver.com/$1 \
                                      [E=proxy-timeout:30]

This allows three different proxies timeouts to the same origin
server (someotherserver.com) based on the URL to the forward
proxy.

Attached is my patch to 2.0.63 to the proxy_http.c file in
modules/proxy.

Thanks,
Ron


Mime
View raw message