Magento Performance Optimization – A Brief Rundown
Magento Performance Optimization
If you’re looking to upgrade Magento with a few useful extensions, we can provide a rundown for you in terms of which ones might be useful for Magento performance optimization. All of the software mentioned below can be set up to work concurrently on a Magento installation.
Using APC as an OPCode Cache Module
Starting with the PHP 5.5 branch, Zend Optimizer+ is directly built into Magento. However, if you’re running an earlier version, you’ll want to install an OPCode Caching module. Our favourite is Alternative PHP Cache – APC.
PHP is an interpreted language. This means that each time a PHP snippet is requested, it reads all of the files and “compiles” them into something that the server can execute: OpCode. OpCode caching caches this generated OpCode, leading to decreased timings when repeat requests are made.
Magento often has hundreds of included files in a single request meaning some real savings can be made, which can mean great things for
OpCaching with APC is system-wide. There is no need to set up Magento to use it—PHP will use it by default.
Memcached
Memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load. Simply put, Memcached alleviates Magento’s heavy hits on your database by caching data away from it.
You’ll need to install Memcache (a PHP extension), and install Memcached – the Memcache Daemon on your server. Across a load balanced / multi server solution, Memcached only has to reside on one server, and the others can all use it. This provides a centralised source for cache management.
Varnish
Varnish is a caching reverse proxy. It’s actually also a http accelerator, it can act as a load balancer and a fail-over system. As a basic concept, it will cache the generated HTML from a page, and serve that to a user rather than making a call to the Magento Framework. This leads to some pretty speedy load times. Magento is very slow to initialise, and if you want your first byte speed down to anything under one second, let alone under half a second – then full page caching is the only way to achieve this.
As mentioned at the beginning of this article, your store should already be fast and you should be looking to reduce server resource—however, Varnish is a great way to reduce your speed to < 300ms.
Varnish requires at least a single page view in order to prime the cache, so it means that your un-cached performance still needs to be high. There are cache-warmers out there (crawlers that will run over your site and prime the cache ready for customer visits) – but we’ve not found any we’d recommend thus far.
Usually, Magento stores fall into two categories, and these will give you an idea of how to configure Varnish.
If your site has relatively low traffic, then you’re going to have a bigger trade-off. Either your TTLs need to be high to ensure a greater hit-rate, or you get up-to-date content. It’s a fine line between them – obviously you can’t have aggressive caching, but frequent changes to content. They don’t play well together. You could, in theory run some sort of cache primer, but I’d expect that it wouldn’t be worth it due to having potentially thousands of URLs.