Amazon AWS Linux Magento

Setup memcached for Magento on Amazon AWS ec2/CentOS/RedHat

What is Memcached and why should we use it?

Memcached is a high-performance memory caching system which stores the data and objects in the system RAM temporarily that could be accessed by different programs. Memcached is a very important component for any dynamic website and when we talk about Magento it becomes very critical to use Memcached service. It boosts the Magento performance significantly. You can easily setup Memcached for Magento on any server. Memcached service may be available by default for few managed servers, you just need to enable it. But for the unmanaged server, you will need to install and setup Memcached.

You can read more about Memcached here.

In this tutorial, I’ll explain you how to install and setup Memcached for Magento on Amazon AWS ec2/Centos/RedHat servers.

Steps to install and setup Memcached for Magento:

Install Memcached

yum install -y libevent libevent-devel
yum install -y memcached

# for php7
yum install -y php70-memcache

# for php5.6
yum install -y php56-memcache

 

Configure Memcached cache size and other options

# open memcached config file
vim /etc/sysconfig/memcached

# Add/update the followingn information and save
CACHESIZE="1GB"
OPTIONS="127.0.0.1"

 

Restart httpd and memcached service

service httpd restart
service memcached restart

 

Add following code in “app/etc/local.xml” under <resources> tag to setup memcached for magento 

<cache>
    <backend><![CDATA[memcached]]></backend>
        <memcached>
            <servers>
              <server>
                <host>127.0.0.1</host>
                <port>11211</port>
                <persistent>1</persistent>
              </server>
            </servers>
            <compression>0</compression>
            <cache_dir></cache_dir>
            <hashed_directory_level></hashed_directory_level>
            <hashed_directory_umask></hashed_directory_umask>
            <file_name_prefix></file_name_prefix>
  </memcached>
</cache>

 

About the author

Sujeet Kr Singh