Free Support via:  +31 (0)20 796 9999
  1. Home
  2. Knowledge Base
  3. Performance hosting with Magento

Performance hosting with Magento

Magento is one of the most popular CMS for e-commerce. It can handle small and large online stores equally well, with a little optimization. This article will help you prepare your CMS to handle large traffic without losing on speed.

The first part of this article will show you standard optimization techniques, suitable for every hosting, even if you are not using the caching options.

Only when you have completed the general optimization, you can proceed to the second part of the article, which shows you how your CMS can benefit from the Performance hosting tools.


Table of Contents:


Performance hosting for Magento

If you have applied the standard optimizations and you or your customers still need an even higher performance setup, the performance of Magento can be significantly optimized by implementing a Redis instance with Full Page Caching.

Enable a Redis instance

For this, you will need to purchase/enable a Redis instance.

The size of the instance depends on the number of pages to be cached, and that differs from site to site.

Generally, an instance of 64M or 128M would suffice.

Install and configure Lesti_fpc with modman

Compatibility and preparation:
  • Lesti_fpc can be used together with Redis (key value store).
  • But Ramdisk should be removed (if it had been used).
  • The www/[magento]/var/cache directory must be emptied.

Modman:

In the Magento back-end follow:
System >> Configuration >> Advanced >> Developer >> Template Settings >> Allow symlinks





Install:

Then go back to the terminal or command prompt, connected to the hosting package.
Make sure you are in the correct directory, otherwise you are headed for heavy troubleshooting!

You have to execute the commands from your Magento directory, in this particular case, Magento is installed in www/magento/

cd ~/www/magento/
wget -q --no-check-certificate -O - https://raw.github.com/colinmollenhour/modman/master/modman-installer > modman.sh
chmod +x modman.sh
./modman.sh
Done. Modman installed in /data/sites/web/USER/bin/modman


Initiate:

~/bin/modman init
Initialized Module Manager at /data/sites/web/ninefortwoperformancecom/www/magento

Install Lesti_fpc:

Enter the following commands in your terminal or command prompt:

~/bin/modman clone https://github.com/GordonLesti/Lesti_Fpc.git

CmCacheBackend_Redis:

Now install CmCacheBackend_Redis

~/bin/modman clone https://github.com/colinmollenhour/Cm_Cache_Backend_Redis.git

Activate a Redis instance:

After that activate a Redis instance via the control panel

  • Name: THISISTHEREDISINSTANCENAME
  • Size: 256MB
  • Password: THISISYOURREDISPASSWORD
  • IP address: THISISYOUREDISIPADDRESS

Create/edit fpc.xml

Return to your terminal. Create/edit your fpc.xml file as you see below. Customize the content of the file and save.

nano app/etc/fpc.xml

~~~~~~

86400 CmCacheBackendRedis

THISISYOUREDISIPADDRESS
THISISYOURREDISPORT 0 0
THISISYOURREDISPASSWORD 0
1
86400 10
1
1
gzip

LESTIFPC_ ~~~~~~

 

Caution: You have to personalize the details, and make sure you are entering the correct server, port and password.

 


 

Afterwards test the connection to the Redis server from the SSH jail. The Redis-cli is now available on the shared SSH jails. It is necessary to reset the SSH to use them. Once this is done you can use the Redis-cli:

 

redis-cli -h THISISYOUREDISIPADDRESS -p THISISYOURREDISPORT
250.250.250.0:10000> AUTH THISISYOURREDISPASSWORD
OK

 

Change local.xml

Afterwards we adjust the local.xml:

 

nano app/etc/local.xml

 

And between the cache tags, where you will usually have the APC, you paste the following code (Again, be careful with the server IP, port and password)

 

<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>THISISYOUREDISIPADDRESS</server>
<port>THISISYOURREDISPORT</port>
<database>0</database>
<password>THISISYOURREDISPASSWORD</password>
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to random connection failures -->
<automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
<compress_data>1</compress_data> <!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_tags>1</compress_tags> <!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_threshold>20480</compress_threshold> <!-- Strings below this size will not be compressed -->
<compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and snappy -->
<persistent>0</persistent> <!-- persistence value, 0: not in use, > 0 used as persistence ID -->
</backend_options>
</cache>



Change Cm_RedisSession.xml

Afterwards enable Cm_RedisSession.xml

nano app/etc/modules/Cm_RedisSession.xml

Change False to True:

<active>true</active>



Now that all this is set up you have to go back in the back end of Magento and do a couple more adjustments to the cache.

Enable Fpc Full Page Cache

In the Magento backend go to System >> Cache management

 Fpc Full Page Cache => Enable

 All other cache => Leave on

Troubleshoot





Troubleshoot

If you do not see FPC Full Page Cache in the list, this means that you are still using cache.
This can empty by emptying the cache directory:

cd var/cache/

rm -rf *

If you still do not see FPC Full Page Cache in the list, this means there is something wrong with your modules installation via modman.

cd ~/www/magento/
~/bin/modman list
Cm_Cache_Backend_Redis
Lesti_Fpc

If you do not see ‘CmCacheBackendRedis’ and ‘LestiFpc’ in the list here, then you know that you have not installed the modules properly.

Test if your Redis is working with your CMS – you should be able to list the Redis keys, by executing the following commands, one after another. Make sure you double-check the host, the port and the password:

redis-cli -h THISISYOUREDISIPADDRESS -p THISISYOURREDISPORT
250.250.250.0:10000> AUTH THISISYOURREDISPASSWORD
OK
keys *

If you do not see any keys, the configuration is not working.

Warm up the cache.

Install n98

If Redis is implemented correctly, we can now warm up the cache.

To do that we install n98

cd /site/bin
git clone https://github.com/netz98/n98-magerun
cd n98-magerun
curl -s https://getcomposer.org/installer | php
php -f ./composer.phar -- install
cd ~/www/magento/


Activate n98

And after n98 is installed, we activate it.

Caution: Make sure you do that from the Magento directory

/site/bin/n98-magerun/n98-magerun.phar sys:url:list --add-products --add-categories 1 > /site/tmp/crawl.txt

Caution: Value ‘1’ can sometimes be ‘0’ or ‘2’ or ‘3’ or higher. This depends on the configuration of the client.

for i in `cat /site/tmp/crawl.txt`; do wget -q $i; done


Now the cache will warm up. You will see that if you open another shell to execute the command ‘ps aux’. You will then see each wget processes.

If the processes stop coming up you know it’s ready.

Check the keys in Redis – the number has increased.

Updated on 15 June 2021

Was this article helpful?