Apache proxypass max config option and maxclients interaction

apache-2.2PROXY

I am having some issues with an apache proxying to a local tomcat instance.

The i have traced the issue down to the way maxclients and proxypass direvtives interact.

in a test environment I set up apache to have 3 max clients and proxypass to have a max of 2 connections to the ajp connector.

maxclients 3
proxypass /player ajp://localhost:8009/player max=2

To illustrate the issue I have firewalled 8009 so requests will have to timeout
If I then make 3 requests to /player and one to a non-proxied file ( 4 in total ) What I expect to happen is this:

  1. 1st request recieved and proxyied
  2. 2nd request received and proxied
  3. 3rd request recieved and as proxypass max reached request queued
  4. 4th request recieved and served as normal
  5. 1st request times out
  6. 3rd request taken from queue and proxied

However What actually happens is this:

  1. 1st request recieved and proxyied
  2. 2nd request received and proxied
  3. 3rd request recieved and waits for proxy connection to free
  4. 4th request recieved and queued as max clients reached
  5. 1st request times out
  6. 3rd request processed
  7. 4th request served

Does anyone know how to force the apache worker to re-queue a request when max proxy connections has been reached so it can move on to non proxied requests?

Thanks

Pete

Best Answer

As documented, you can set various additional paremeters to control the behaviour of mod_proxy.

The most useful for you will be:

acquire (no default)
If set this will be the maximum time to wait for a free connection in the connection pool, in milliseconds.
If there are no free connections in the pool then Apache will return SERVER_BUSY status to the client.

Set this to 0 so that when the pool is used up, it instantly returns a 503 status to the client.