You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ruediger Pluem <rp...@apache.org> on 2006/04/14 13:04:56 UTC

Copied workers in balancer?

While investigating PR 38227
(http://issues.apache.org/bugzilla/show_bug.cgi?id=38227) I stumbled accross
ap_proxy_add_worker_to_balancer:

PROXY_DECLARE(void)
ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer *balancer,
                                proxy_worker *worker)
{
    proxy_worker *runtime;

    runtime = apr_array_push(balancer->workers);
    memcpy(runtime, worker, sizeof(proxy_worker));
    runtime->id = proxy_lb_workers;
    /* Increase the total runtime count */
    proxy_lb_workers++;

}

Does anybody remember why we are making a copy of the worker?
This means that if you are only using a balancer you have the workers
twice (one in the balancer, one in the worker list). This seems to be
a waste of resources.
Even if you use a worker inside *and* outside a balancer, would it hurt
if these are the same?
>From a first glance I would say that some changes need to be done to avoid
a copy. The current approach seems to be at least somewhat convenient
from the developer side to handle the members of a balancer easily.


Regards

Rüdiger


Re: Copied workers in balancer?

Posted by Ruediger Pluem <rp...@apache.org>.

On 04/14/2006 05:20 PM, Mladen Turk wrote:
> Ruediger Pluem wrote:


>>
>>
>> Ok, I understand these goals, but as far as I can see from the current
>> code
>> they do not share the error status as they are using different scoreboard
>> slots and thus w1 from b1 is using a different proxy_worker_stat then
>> w1 from b2.
>>
> 
> But they are (at least they were).
> proxy_worker struct that we memcpy to the new slot
> in ap_proxy_add_worker_to_balancer has a pointer
> to the proxy_worker_stat, so they are shared.

Correct, but at the point of time we copy this pointer it, is not
initialized. This is done later for each copy of the worker in
ap_proxy_initialize_worker_share. Thus they point to different
proxy_worker_stat 's.

> 
> That was the reason why those two structures are
> separated at the first place.

Thanks for clarification.

Regards

Rüdiger



Re: Copied workers in balancer?

Posted by Mladen Turk <mt...@apache.org>.
Ruediger Pluem wrote:
> 
>> This allows to have common worker parameters like error status
>> shared across multiple balancers, while maintaining per-balancer
>> worker data.
> 
> Ok, I understand these goals, but as far as I can see from the current code
> they do not share the error status as they are using different scoreboard
> slots and thus w1 from b1 is using a different proxy_worker_stat then
> w1 from b2.
>

But they are (at least they were).
proxy_worker struct that we memcpy to the new slot
in ap_proxy_add_worker_to_balancer has a pointer
to the proxy_worker_stat, so they are shared.

That was the reason why those two structures are
separated at the first place.


Regards,
Mladen.


Re: Copied workers in balancer?

Posted by Ruediger Pluem <rp...@apache.org>.

On 04/14/2006 02:17 PM, Mladen Turk wrote:
> Ruediger Pluem wrote:
> 
>>
>> Does anybody remember why we are making a copy of the worker?
> 
> 
> Usually a worker represents a backend appserver instance.
> Now you can have multiple load balancers with different
> lb factors for the same set of workers,
> but for the different application mappings.
> 
> Lets say that you have workers w1, w2, w3, and load balancers b1 and
> b2. Both b1 and b2 have the same set of workers w1-w3, but with the
> different lb factors for each worker, so that for b1 its: 1:1:2
> and for the b2 it's 2:2:1, etc.

So that would be something like:

<Proxy balancer://b1>
BalancerMember http://w1 loadfactor=1
BalancerMember htpp://w2 loadfactor=1
BalancerMember htpp://w3 loadfactor=2
</Proxy>

<Proxy balancer://b2>
BalancerMember http://w1 loadfactor=2
BalancerMember htpp://w2 loadfactor=2
BalancerMember htpp://w3 loadfactor=1
</Proxy>


> 
> This allows to have common worker parameters like error status
> shared across multiple balancers, while maintaining per-balancer
> worker data.

Ok, I understand these goals, but as far as I can see from the current code
they do not share the error status as they are using different scoreboard
slots and thus w1 from b1 is using a different proxy_worker_stat then
w1 from b2.

Regards

Rüdiger


Re: Copied workers in balancer?

Posted by Mladen Turk <mt...@apache.org>.
Ruediger Pluem wrote:
> 
> Does anybody remember why we are making a copy of the worker?

Usually a worker represents a backend appserver instance.
Now you can have multiple load balancers with different
lb factors for the same set of workers,
but for the different application mappings.

Lets say that you have workers w1, w2, w3, and load balancers b1 and
b2. Both b1 and b2 have the same set of workers w1-w3, but with the
different lb factors for each worker, so that for b1 its: 1:1:2
and for the b2 it's 2:2:1, etc.

This allows to have common worker parameters like error status
shared across multiple balancers, while maintaining per-balancer
worker data.

Regards,
Mladen.