Storing user sessions on Amazon Elastic Cache

Here in our company, we moved from Elasticbeanstalk enviroments to our customized servers which are currently behind on manually created elastic load balancer. The reason to move was limited freedom in terms of Scalability. Beanstalk environments were set to auto-scale automatically and It was handling the user sessions through its own auto-created load balancers.

When we moved to our own cluster of servers behind a load balancer, we decided to move the handling of application sessions completely from instance storage to Amazon Elastic Cache service. We are using Memcached engine inside Elastic Cache which is widely adopted memory object cache system and very easy to use.

Now, the next question was how to connect your application with a session handler. We are currently using PHP as our backend language.

Below are the settings which needs to be updated in your PHP.ini

For more info – http://php.net/manual/en/memcached.sessions.php

If you are behind a load balancer, try creating a script which will set this setting up for you at the start of each server.

After this, we have a centralized session storage using memcached.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">