I previously submitted the lb 'busyness' patch for mod_jk, and it has worked
well for us.
Now we need some additional functionality from mod_jk and I'd like to get
feedback here first before I start patching. I'd prefer to implement
something that is generally useful to others, and submit the patch, so it
becomes part of the mod_jk codebase.
First, the problem. Currently there isn't any direct way for a servlet to
tell mod_jk that it should be marked as being in 'Error' state (as being
down). We have a backend HTTP service that requires high availability. If
the servlet detects that something is wrong, it should "take itself out" of
the mod_jk load balancer, at least temporarily. There are two ways I can
think of to accomplish this right now. The first, which I've done, is set
the reply_timeout to a fairly low value, like 4000ms, and then make the
servlet intentionally sleep for 5000ms to cause it to go into Error state.
This works, but having the reply_timeout so low is a risk -- if the backend
servers are slow for some reason (copying large files, etc), they can all be
marked as down -- oops. The second method, which I have not tried, is to
have the servlet do a GET request to the mod_jk JkStatus page, to take
itself out of rotation. While it may work, I just don't have good feelings
about this method. If anyone has other suggestions on ways for a servlet
to force itself to be marked as in 'Error' state, please reply.
So, I looked through mod_jk code hoping that I could have the servlet throw
an HTTP 50x error that mod_jk would interpret as "down", but no such luck.
There has been talk before about writing a "meta" communication layer
between servlets and mod_jk. This could open up the doors to some cool
things: Servlets could provide JK with load information, average response
times, available webapp contexts, etc. See this thread:
For my current purposes, I just need the servlet to tell mod_jk "even though
I'm available, mark me as in Error state!". How should we do this? Using
a "hidden" HTTP response header might work for communicating general
strings, or returning certain "reserved" HTTP responses (HTTP 599 = error,
etc) -- these are two options that come to mind. I'm willing to implement
and test the mods, including under heavy load.