Project

General

Profile

can I use HA as loadbalancer

Jun Liu
Added almost 4 years ago

Hi,

I want to set up a tigase cluster with 3 servers, I want to use HAProxy as the load balancer, want to know that how can the heartbeat from mobile app can be direct to the right server?

is it correct that use HA as the loadbalancer?

Thanks


Replies (7)

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

It's possible to use HA as loadbalancer. Particular usage will depend on whether you would use socket connections or BOSH. In the former case directing heartbeat from mobile client to proper Tigase node will be handled by HA itself. In the latter in each BOSH response from Tigase there is an attribute with hostname so you will be able to access server directly (if possible).

Added by Jun Liu almost 4 years ago

Hi Wojciech,

Thanks for your reply

What if HA directs the data randomly? for example, one user's app connects to server1, what if the heartbeat is directed to sever2, whether it would cause problem?

actually, I have a question, which might be naive, when the mobile app client communicates with tigase, whether it's long connection? if it is, the client need to send heartbeat to server, will tigase route the heartbeat to the right server in cluster mode? like what it does for xmpp packet

Thank you very much

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

OK, before continuing - please define what you mean by "heartbeat" and what kind of connections (socket/bosh) are you using?

Added by Jun Liu over 3 years ago

to keep the connection alive, the client would send 0 length packet to server, right? I think this packet should be sent to the same server

Added by Wojciech Kapcia TigaseTeam over 3 years ago

It's one of the options, but this would imply using whitespace ping (as specification names it) which further implies that you would be using regular socket connections, which are, well, permanent, therefore once established all transmission over such socket will always reach same cluster node/server.

Added by Jun Liu over 3 years ago

I have tried the HA (tcp mode), seems it can't work, there're two servers behind the HAProxy

the client would be disconnected every 30s, I use tcpdump to check the reason, here are some findings

  1. the client would send a small packet every a certain time to keepalive, but HA would use a different port to route the packet to the destination server

  2. so if I increase the timeout setting in HA configuration, the client would be online for a longer time, so I think the reason is HA uses different port to route the heartbeat packet, and cause the connection port( client connect with server the first time) was closed

  3. one strange thing is that if I chat through the client, from tcpdump, I can see that HA uses the original connection port to route the message packets, and the client would not be disconnected

Thanks

Added by Wojciech Kapcia TigaseTeam over 3 years ago

Jun Liu wrote:

I have tried the HA (tcp mode), seems it can't work, there're two servers behind the HAProxy

the client would be disconnected every 30s, I use tcpdump to check the reason, here are some findings

Again, as I asked before:

please define what you mean by "heartbeat" and what kind of connections (socket/bosh) are you using?

  1. the client would send a small packet every a certain time to keepalive, but HA would use a different port to route the packet to the destination server

Please give more details:

  • what port number?

  • what connection type?

  • what is the packet?

This is essential before proceeding.

  1. so if I increase the timeout setting in HA configuration, the client would be online for a longer time, so I think the reason is HA uses different port to route the heartbeat packet, and cause the connection port( client connect with server the first time) was closed

  2. one strange thing is that if I chat through the client, from tcpdump, I can see that HA uses the original connection port to route the message packets, and the client would not be disconnected

With the vague information you are providing it's impossible to provide you with solution. Please share tcpdumps, packets, port numbers, etc.

    (1-7/7)