• Techmenu Home
  • Techmenu Mail
  • Techmenu Map

Magento Session Failover with memcached

When you chase 100% of uptime for your ecommerce business it is very important that ALL components in the hosting infrastructure are redundant and provide failover.


While it is straightforward to provide failover for application, database and filesystem nodes, memcache is not designed to provide failover / redundancy. It is absolutely fine if you use memcache for fast cache which can be rebuilt whenever one node goes down. However in case with visitors sessions, they will just loose their baskets when a node goes down and the installation is switched to another blank memcache instance.


Hopefully, latest versions of php-memcache module do provide failover support. This are the steps to follow when setting up memcache failover for Magento:


1. Make sure you have both modules installed: php-memcache (>3.0.5) and php-memcahced.

2. Place the following settings at the end of .htaccess file:

# these settings are for 2 memcache nodes

# activating memcached failover

php_value memcache.allow_failover 1

# quantity of memcached nodes used

php_value memcache.max_failover_attempts 2

php_value memcache.redundancy 1

# the number below needs to be N+1 if you have N number of memcached nodes

php_value memcache.session_redundancy 3

php_value memcache.hash_strategy "consistent"


3. In local.xml, sessions setup should look like this:


<session_save_path><![CDATA[tcp:// ,tcp://]]></session_save_path>
(obviously provide your own ip addresses and ports)


If you would like us to help you with the setup, feel free to get in touch.