2

We are load balancing 2 servers hosting an identical Craft environment.

When clicking around in the admin a user will get logged out after 30 seconds and sometimes even faster when browsing in the admin panel.

I am unable to set the load balancer to sticky sessions due to the load balancer sitting behind a Firewall which NAT's inbound traffic. So the load balancer see's all inbound traffic as a single IP.

Is there anything else that can be done to resolve this issue?

1

If you can't enforce sticky sessions, then you'll need to provide a common place for all load balanced web server to save their PHP session files.

By default PHP session files are file based and saved to whatever path the php.ini session_save_path is set to. You could change that to an NFS share path.

If you had an in-memory key=>value store (like Redis, Memcached, etc.) you could configure PHP to save its sessions there.

If you wanted something more persistent, you could configure PHP to save sessions in a database.

On top of that, if you're not using stick sessions, you'd want to set a consistent appId and validationKey across every web server so they can decrypt Craft/PHP cookies using the same tokens.

3
  • Hey Brad, we currently have php sessions saving to the generic /var/lib/php/session/ directory. NFS share path could be a possibility. We also use MemcacheD as our 'cacheMethod'. How would I go about setting php sessions to use MemcacheD? Both servers use the same cache server so that would be a common ground. We also currently have the appID and validationKey set consistent across all load balanced servers. Thanks, Adam Jul 26 '17 at 15:15
  • You'd have to set a custom session.save_handler and session.save_path. Similar to examples here digitalocean.com/community/tutorials/…
    – Brad Bell
    Jul 26 '17 at 18:10
  • Thanks, just found a few of those tutorials.. Looks like there's a bug with php7 and or the version of memcacheD I'm using. Currrently getting : Failed to create session ID: memcached. With the hander and save_path set. I can create telnet connections from my web-server to my memcache servers just fine. Jul 26 '17 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.