Jump to content

Load Balanced Website - Does WHMCS Work?


Recommended Posts

Hello,

 

I have a load balanced setup and I want to have WHMCS on there for my billing but I'm having a lot of issues.

 

1 load balancer - handles traffic

2 app (website) servers - identical servers, identical files, basically they're mirrored/replicas

1 database/cache server - this holds the centralised database for the 2 app servers and handles sessions.

 

I can't seem to get the sessions to work properly. In my PHP ini file, I have tried both memcache and redis, pointing to the cache server IP, I know this is working as my CMS is using the same setup and it works perfectly. The CMS is based on Laravel.

 

So for testing, I disabled one app server. If I use either memcache or redis as the session handler, I can log in to WHMCS admin but I cannot save any forms due to token missmatch and I cannot access the settings area as the confirm identity won't work. Same goes for the front end, I can login as a user but saving details doesn't actually save - it just goes back to the main account page. Stick the session handler back to files and it works - but then this won't work when I fire up the second app server due to the load balancer randomly placing a user on which ever server.

 

I have to assume there's companies out there using WHMCS on a load balanced setup - can someone please help with the sessions side as it's getting to the point where I'm about to give up.

 

 

Thanks!

Link to comment
Share on other sites

Could you share what load balancer are you using? Are you passing the users IP to the servers by using the header X-Forwarded-For or similar? What layer is it load balancing?

 

It seems to me there is a split session. WHMCS should work behind a load balancer (didn't tested) but I don't see a reason why it would not work if the load balancer is invisible to the software. I managed to make more complex stuff with sessions and databases to work behind load balancers.

 

What errors does the server give when you try to save data? It works with only one server up but not both? So you are trying an Active-Active setup instead of Active-Passive. I would first try the second one before trying to pull up 2 installations at the same time, that could be tricky to get working. If this is a problem in your load balancer config, or server you are lucky, you can make it work. If this is some problem in WHMCS you are pretty much screwed because everything is encoded and you are not going to be able to fix it, they will tell you to put in a Feature Request and maybe 3 years later they will build it (maybe). That is the only downside with WHMCS today, if you need something a bit more complex you are basically without any option as you cannot change core parts of how the logic in the software works.

Edited by yggdrasil
Link to comment
Share on other sites

  • 3 weeks later...

I am in exactly the same situation. I've managed to set up a load balanced whmcs before. The situation is different now.

 

What I was doing back then:

 

Nginx as load balancer and use sticky sessions. This basically means that the request a user makes ends up on the same node as his previous requests. this works, you can find a lot of good information about sticky sessions on google.

 

My situation now:

 

A large docker swarm cluster, HAproxy load-balancing with service discovery, database cluster and database proxys. Sticky sessions are out of the question here without breaking other applications on the cluster. The concept is quite simple, there are x worker nodes in the swarm, they exist on our main infrastructure and on different locations around the world. Every datacenter has its own managers and they function as entrypoint to the cluster routed with BGP anycast DNS. Important apps and cache instances are scaled across the cluster to cover every datacenter to reduce latency to the minimum

The whole damn thing is production ready and works with all our custom apps (PHP/laravel, node, wordpress, ELK,...) and they all use memcached as session/cache driver. WHMCS does work, until I start scaling the service across the cluster. Then I have the exact same behaviour as you describe.

 

Maybe it is time to ask WHMCS if I can buy/lease an unencrypted version to do some tweaking, this has been going on for weeks now...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated