2

We've recently set up a Redis cluster to handle our PHP sessions since we use a load balancer to direct traffic into different craft instances.

We're seeing issues with redis when making back to back PHP session calls (using craft wrapper) very quickly. If we update a variable in the httpSession and then try to update it/get it very quickly it isn't updating. If we wait to access it then it is updated correctly.

How it's set up: We modified the Apache2 php.ini to update the session handler to redis and the save path to our redis cluster (bypassing doing this via Craft). So Craft still uses its' default session handling but when it makes the request to save the session it gets redirected by apache to our redis.

Is it more beneficial to tie this to Craft by updating the General.php with the session override options? Will we see faster/better session handling? Is there a session lock happening in craft? Is Craft opening/closing the session after each httpSessionService call?

1

I can't say for certain if you would see faster session handling if you added the overridePhpSessionLocation config key, but have you added the appId and validationKey configuration keys? I was recently having issues in my load balanced environments because these keys were not set.

| improve this answer | |
  • I have an appId in my General.php but not a validationKey. It looks like craft automatically generates one though, would this possibly fix it? It's weird because when we attempt to make several updates to the same session variable very quickly they get out of sync for some reason. – Exziled Nov 17 '16 at 21:19
  • I'm admittedly not an expert on this, but i imagine it could cause issues if the validation key isn't the same for every server in the cluster. Especially if data from those servers is all coming back to a centralized Redis box. – Liam Scott Nov 17 '16 at 21:27
  • Based on that last comment though you might also wanna comb through your sessions work flow for any race conditions. – Liam Scott Nov 17 '16 at 21:29

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.