Magento Apc and Memcached Speed up Magento

I hear a lot of time that people complaints about “Magento is very slow”. In my opinion Magento is not a good solution if you are hosting it in a Shared environment, If you’ve a dedicated server then YES, use it otherwise just use baby e-commerce software available online.

This article will focus on configuring and using APC and/or Memcached.

I am sharing my local.xml file.

Look for <cache>, But before you even do any of that, you need to make sure you’ve Memcached & Apc installed and configure.

Revision Feb-15-2016

The (last) version 5.1.2 of APCu don’t support PHP5 (only PHP7) so you need to set a specific version instead of beta tag :

sudo apt-get install php-pear php5-dev make libpcre3-dev php5 memcache memcached php-pear

pecl install apcu-4.0.10
&& echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini
<?xml version="1.0"?> <!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magento.com for more information. * * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> <config> <global> <install> <date><![CDATA[Fri, 10 Jul 2015 02:58:56 +0000]]></date> </install> <crypt> <key><![CDATA[321654]]></key> </crypt> <disable_local_modules>false</disable_local_modules> <resources> <db> <table_prefix><![CDATA[]]></table_prefix> </db> <span style="color: #ff0000;"><cache> <backend>memcached</backend> <memcached> <servers> <server> <host><![CDATA[127.0.0.1]]></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[]]></file_name_prefix> </memcached> </cache></span> <default_setup> <connection> <host><![CDATA[localhost]]></host> <username><![CDATA[root]]></username> <password><![CDATA[LLKDIWWW221#]]></password> <dbname><![CDATA[store]]></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[db]]></session_save> <span style="color: #ff0000;"><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[127.0.0.1]]></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[]]></file_name_prefix> </memcached> </cache> <cache> <backend>apc</backend> <slow_backend>database</slow_backend> <slow_backend_store_data>0</slow_backend_store_data> <auto_refresh_fast_cache>0</auto_refresh_fast_cache> <prefix>TTDINC_</prefix> </cache></span> </global> <admin> <routers> <adminhtml> <args> <frontName><![CDATA[admin]]></frontName> </args> </adminhtml> </routers> </admin> </config>

In my ubuntu environment my apcu.ini is located at

/etc/php5/mods-available/apcu.ini

xtension=apc.so
extension=apcu.so
apc.enabled=1
apc.shm_size=512M
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
apc.stat=0
apc.optimization=0
apc.shm_segments=1
apc.enable_cli=1
apc.cache_by_default=1

Leave a Reply

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