0
votes

I have an ejabberd cluster in AWS that I want to load balance. I initially tried putting an ELB in front of the nodes, but that makes the sessions to be non-sticky. I then enabled proxy protocol on the ELB and introduced an HAProxy node between the ELB and the ejabberd cluster. My assumption / understanding here was that the HAProxy instance would use the TCP proxy and ensure the sessions are sticky on the ejabberd servers.

However, that still does not seem to be happening! Is this even possible in the first place? Introducing the cookie config in the HAProxy.cfg file gives an error that cookies are enabled only for HTTP, so how can I have TCP sessions stay sticky on the server...

Please do help as seem to be lost on ideas here!

2
I remember a recent question from another user who seemed to think enabling proxy protocol on an ELB would somehow make sessions sticky for ejabberd, which of course made no sense. Your setup, with HAProxy after ELB, at least makes sense, but will need to be configured with something like stick on src... but I'm still unclear... why does stickiness matter at all? If a connection comes in to a different server, why is that important? If you accomplish this, will it solve your actual problem? - Michael - sqlbot
Hi @Michael-sqlbot - thanks. Yes I saw that question - I didnt get the point either. For my case, if I dont make the sessions sticky, the user's connection stream keeps on rotating amongst the different servers, and there is no long-running stream. So essentially, within the same session, the user gets logged out and logged in multiple times. I think I have to probably dig deeper into the ejabberd behavior here - Mickael has mentioned below the need for stickiness not being there for ejabberd, so I'll further check... Thanks! - Samantha
ELB will close an idle connection after 60 seconds by default, by design. Have you reconfigured the timeout to a higher value? - Michael - sqlbot
Thanks @Michael-sqlbot .. yes I did try that too with 10 mins... let me see further what could be wrong... Thanks much for your inputs so far... - Samantha

2 Answers

0
votes

ejabberd does not require sticky load balancing. You do not need to implement this. Just use ejabberd cluster with ELB or HAProxy on front, without stickyness.

0
votes

Thanks @Michael-sqlbot and @Mickael - seems it had to do with the idle timeout in the ELB. That was set to 60 seconds, so the TCP connection was getting refreshed if I didnt push any data from the client to the ejabberd server. On playing with that plus the health check interval, I can see the ELB giving me a long-running connection... Thanks.

I still have to figure out how to get the client IP's captured in ejabberd (believe enabling proxy protocol on the ELB would help) but that is a separate investigation...