Take the 2-minute tour ×

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?

share|improve this question
add comment

2 Answers

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:


    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.

share|improve this answer
+1 for using a tool designed for the job. –  larsks Nov 23 '10 at 17:17
add comment

Have you tried setting


in your config?


share|improve this answer
I have, this doesn't apply to time waiting to a free proxy worker. –  Michael Sofaer Oct 5 '10 at 22:37
add comment

Your Answer


