PHP Sessions on Auto-Scaling Servers

amazon-web-servicessticky-sessions

(Apologies for cross-posting with SO. I wasn't sure where it was more appropriate.)

I'm working on a PHP web app deployed to Amazon Web Services. We have load balancers in front of auto-scaled application servers.

The problem we're facing at the moment is handling sessions. While sticky sessions would be a reasonable solution, we'd like to persist sessions for quite a long time (weeks ideally). This is likely to impair the performance of the load balancer over time. Also, using auto-scaling will mean that, from time to time, we'll remove a server and thus lose all of the active sessions on it. Of course, we could just use a common database to store sessions, but I'm a bit concerned about performance if every request requires another round-trip to the DB.

I'd be grateful if you could suggest any solutions that have worked for you, or any ideas that we could try.

Thanks in advance for your help,
Ross

Best Answer

PHP store it's session in plain files. Have you tried storing them on a common storage?

Similiar question: Share PHP sessions in cloud file system

Here is an article about this specific issue and different approaches: http://kevin.vanzonneveld.net/techblog/article/enhance_php_session_management/

Related Topic