[ejabberd] External Component Load Balancing

Pedro Melo melo at simplicidade.org
Wed Jan 27 11:04:58 MSK 2010


Hi,

On Wed, Jan 27, 2010 at 3:49 AM, Mike Mahoney
<mmahoney at palantirisystems.com> wrote:
> I'm still a bit confused about the 'source' domain_balancing option.  If
> there were two components and two clients, and componentA sent an IQ to
> clientA, I understand that it would get the response.  Would all requests to
> clientA have to be routed through componentA now, or could componentB also
> send IQs to clientA and be guaranteed to get the response?

No, componentA will get a response from clientA, and componentB will
get the responses from clientB. Thats why you need to be sure that
either:

 1) only componentX will send IQs to clientX;
 2) move your state (all that you need to process the reply) to an
external database so that any component can process any response.


> Also, when you use domain_balancing_component_number do you specify the
> number of components that will be connected?

If you have to keep clients bound to a specific component (like ICQ,
MSN, AIM, Yahoo gateways, that have to keep a TCP connection tied to a
specific JID) then you need domain_balancing_component_number.

The load balancing algorithm uses a set of buckets, one per component
instance. If you don't use domain_balancing_component_number, the
number of buckets is the number of active instances at any point in
time. The algorithm hashes the source jid to a integer modulo the
number of buckets and picks that one. If an instance goes down, the
number of buckets is lower, and the distribution of most of your
source jids changes.

With domain_balancing_component_number, the number of buckets is
constant, so the hashing of source jids is stable. You set it to the
number of instances you have. If one instance goes down, all the
clients that where using that instance will lose their sessions and
will remain without service until that instance is restarted.

>  Ex: {domain_balancing_component_number, "my.domain.com", 4}.

This means that you should have 4 instances of the component serving
'my.domain.com'.


> My components don't store any real session information, they just facilitate
> a single request/response, so {domain_balancing, "my.domain.com", source}
> will probably be sufficient, even without an external session store.

Yes they do. If you need the response to return to the instance that
sent it, that's because there is some information in the instance
memory that you need when the reply comes. Thats your "session
information" and the IQ ID is your session_id.

If you don't have this, then any instance could receive the answer.

Bye,
-- 
Pedro Melo
http://www.simplicidade.org/
xmpp:melo at simplicidade.org
mailto:melo at simplicidade.org


More information about the ejabberd mailing list