<img alt="" src="https://secure.leadforensics.com/150446.png " style="display:none;">
Go to top icon

How To Implement AWS ElastiCache in Magento

Vidya Palaskar Dec 29, 2014

AWS ElastiCache Magento AWS ElastiCache in Magento cloud computing Technology

For any web application, caching plays a vital role in performance. We all know about Magento as a powerful e-commerce framework. Its community version though is slower. However, there are ways to speed it up as well.

One such tool is Amazon's ElastiCache. ElastiCache supports Memcached which is an open-source in-memory caching engine. Memcached is suitable if the data is large and distributed on multiple servers, and that’s the reason ElastiCache supports the engine. For more on Amazon's ElastiCache, refer to its official page.

Magento has numerous included files in a single request which means that a good amount of server load can be curbed through AWS ElastiCache. It reduces server load by storing cache in different nodes. This caching mechanism helps take care of Magento’s heavy hits on the database by caching data away from it. To enable Memcached into Magento, modify main configuration file of Magento i.e. local.xml

Steps to implement ElastiCache with Magento :

1) Get all AWS cache cluster nodes.

2) Open local.xml Magento from the 'app/etc/local.xml'

- Inside global tag below <session_save><![CDATA[files]]></session_save> add the following piece of code -

<cache>
	  <backend>memcached</backend><!-- apc / memcached / empty=file -->
	  <memcached><!-- memcached cache backend related config -->
	    <servers><!-- any number of server nodes can be included -->
		  <server>
	        <host><![CDATA[yourserver1.n3vrvk.0001.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
	        </server>

	<server>
	        <host><![CDATA[yourserver1.n3vrvk.0002.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
	  </server>
               <server>
	        <host><![CDATA[yourserver1.n3vrvk.0003.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
	   </server>
 <server>
	        <host><![CDATA[yourserver1.n3vrvk.0004.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
	   </server>
     	<server>
	        <host><![CDATA[yourserver1.n3vrvk.0005.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
              </server>
         </servers>
  <compression><![CDATA[0]]></compression>
  <cache_dir><![CDATA[]]></cache_dir>
 <hashed_directory_level><![CDATA[]]></hashed_directory_level>
 <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
<file_name_prefix><![CDATA[myCache_]]></file_name_prefix>
</memcached>
</cache>

Your local.xml file will look like the screenshot below.
3) Save your file and enjoy your Magento store.
For more details information on creating AWS ElastiCache nodes, read this blog.

<config>
    <global>
        <install>
            <date><![CDATA[Thu, 01 Nov 2012 09:24:16 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[test]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
<table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[Your_database_hostname]]></host>
                    <username><![CDATA[your_database_username]]></username>
<password><![CDATA[your_database_password]]></password>
                                                                                <dbname><![CDATA[your_databaseName]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type> 
<pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[files]]></session_save>
                <cache>
                  <backend>memcached</backend><!-- apc / memcached / empty=file -->
                  <memcached><!-- memcached cache backend related config -->
                    <servers><!-- any number of server nodes can be included -->
                                  <server>
                        <host><![CDATA[server1.0001.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
                        </server>

                                                <server>
                        <host><![CDATA[server2.0002.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
                        </server>

                                                <server>
                        <host><![CDATA[server3.0003.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
                        </server>

                                                <server>
                        <host><![CDATA[server4.0004.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
                        </server>

                                                <server>
                        <host><![CDATA[server5.0005.use1.cache.amazonaws.com]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
                        </server>

                    </servers>
                    <compression><![CDATA[0]]></compression>
                    <cache_dir><![CDATA[]]></cache_dir>
                    <hashed_directory_level><![CDATA[]]></hashed_directory_level>
                    <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
                    <file_name_prefix><![CDATA[iwsCache_]]></file_name_prefix>
                  </memcached>
  </cache>

    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

Similar Blog

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.