0

I have a web service that must always respond to requests in under 5 seconds. I'm using Apache to proxy requests to a cluster of backend workers. When all the workers are full, Apache queues up requests and waits for a worker to be free.

I have set Timeout 5 in my VirtualHost

mod_proxy appears to take over the Timeout directive and use it to limit how long a worker can take to respond to a request. This means that requests can back up in the queue, and they don't get timed out in 5 seconds. I need to respond with a 504 if I can't turn a request around in under 5 seconds total, the time spent in the proxy worker isn't what I want to limit, it's the total open connection time. Alternatively, if there was a way to limit the time spent waiting for a free worker, that might work, but none of the balancer directives seems to do that (I've tried a lot of them)

How can I make Apache time out requests in 5 seconds, no matter what is going on in my worker cluster?

2 Answers 2

2

Have you tried setting

ProxyTimeout

in your config?

http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxytimeout

1
  • I have, this doesn't apply to time waiting to a free proxy worker. Oct 5, 2010 at 22:37
1

You probably want to use a better tool, like HAProxy, which is designed just for proxying and has very flexible timeout configuration that will let you specify the overall timeouts or timeouts just for requests in the queue:

EG:

defaults
    balance roundrobin
    mode http
    timeout connect 4000ms
    timeout queue   1000ms
    timeout client  4000ms
    timeout server  4000ms
    timeout http-request  4000ms
    option httpclose
    option redispatch

You also get the benefit of not needing a thread per request.

1
  • +1 for using a tool designed for the job.
    – larsks
    Nov 23, 2010 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .