Making Magento go fast by Thijs Feryn @ThijsFeryn at #phpworld

Making Magento go fast by Thijs Feryn @ThijsFeryn at #phpworld Magento can be a little slow, but it's tremendously flexible.

Presenting today from the perspective of a hosting company employee who knows a lot about PHP but not a lot about Magento and approached it from a hosting/operational standpoint.

Remember the basics - activate caching, flat catalogs and JS & CSS minifcation.

The Magento compiler is a lie - it's invented for people who have no bytecode caching, but everyone should have that now.

Magento cache by default is on the disk - var/cache/

Move the Magento cache to somewhere faster. Could try APC or memcached. Memcached support allows multiple servers.

Magento uses a 2-level cache, a fast backend (adapter) and slow backend (disk).

You can put your slow backend (var/cache)on tmpfs.

PHP is slow - especially the older versions.

Remember - many types of PHP caching doesn't work well with fast-cgi because everything is in multiple, separate processes. Every process has its own APC cache.

With php-fpm you can configure a master process that stores the byte code cache so each child process uses same cache.

Opcache is awesome and a lot faster than APC.

Get all of your caches in memory!

The database is important for Magento performance - give MySQL more RAM. MySQL should use 80% of your database server's memory.

If you have lots of traffic to Magento, try turning off query caching and use the memory for the buffer pool and other uses in MySQL.

Check the setting innodb_flush_log_at_trx_commit - try to change it to 2 or 0.

Setup 2 database servers - one for reads, and one for writes.

Redis is GREAT - use it! Redis has built-in deplication, multiple data types, doesn't require a 2-level cache.

Store your sessions in redis so that sessions are shared between all of your web nodes.

Varnish is fast and scales - sites have powered 40 million users per day with only 2 Varnish servers.

Varnish only works on static items - product catalog and CMS pages. Not on checkout. It's great for static content, but it doesn't have SSL support. You have to terminate SSL before it gets to Varnish - use something like haproxy or nginix.

Look at using Turpentine - it allows you to use ESI or AJAX with Varnish and Magento.

If you can't use Varnish, use Lesti FPC.

If you're using Varnish or LestiFPC, turn off the visitor log tables, because they are no longer accurate. Convert them to blackhole tables.

Magento's default search can be a full-text search on the database - replace this with something better. Try using elasticsearch.

Host static files separately on a CDN.

Use Redis "clustering" to remove Redis as a single point of failure. Try Redis-cluster or Redis Sentinel - there's a Redis Sentinel patch for Cm_Cache_Backend_Rails.

Subscribe to Leadership in Commerce by Joshua Warren

Sign up now to get access to the library of members-only issues.
Jamie Larson