On Sep 25, 2006, at 8:54 AM, Garrett Rooney wrote:
On 9/25/06, snacktime <[EMAIL PROTECTED]> wrote:
I have very little C programming experience, but I've decided to
tackle adding another load balancing method to mod_proxy_balancer.
The reason for a new lbmethod is to have something that works nicely
with ruby on rails. Both ruby and rails are not thread safe, which
poses certain challenges. Right now the most popular way of hosting
rails apps is using Mongrel http://mongrel.rubyforge.org/.
Mongrel is
a simple http server which loads and runs rails, but it can only
process one request at a time due to rails not being thread safe. So
a fairly good way to serve up rails is to have a cluster of mongrels
behind apache using balancer. The problem is when you have a mix of
short requests with longer requests. Mongrel will queue up
connections but can only service one at a time, so one mongrel might
have several slow requests queued up, and another mongrel might only
be serving one request.
So, what I'm trying to do is implement a new lbmethod that will only
proxy a request to a balance member that has no requests currently
being processed. If there are no more balance members available, I'm
thinking the best thing is to implement a short wait cycle until a
free mongrel is available, and possibly log a warning so you know
that
you need to add more mongrels to the cluster, and more balance
members
to apache.
Any advice or hints are more then welcome, especially if for whatever
reason this is going to get really complicated.
The major problem you're going to have is that you'll have to use some
sort of shared memory (or a similar technique) to coordinate
information between the various worker processes. Since Apache can
run in multiprocess mode in addition to multithreaded modes you can't
easily tell other workers "hey guys, I've got this one don't use it
till I'm done". It'd be a useful problem to solve in a generic manner
though, as the mod_proxy_fcgi module has a simlar problem.
Actually, I've added the 'busy' struct element which
could be used for that... The orig intent was to add
the mod_jk "busyness" LB method, but it would also
serve as a flag that the member is busy ;)
As of now, neither Trunk or 2.2.x do anything with busy,
but that will change soon :)