Axel's root Blog

for nerds only - little stories from the everyday sysadmin life with problems and their hard-to-find solutions

Magento Performance Tuning

2009-10-14 by Axel Reinhold, tagged as magento, performance
Web application tuning is an art - especially magento as heavyweight php application challenges - but with a couple of settings it performs good.

Compiling PHP with server optimized compiler options can really boost PHP's raw speed. I used gcc-4.4.1 with -O3 -march=nocona -msse -mmmx -msse2 -msse3 -mfpmath=sse -fomit-frame-pointer -funroll-loops -fno-stack-protector and did not include the Suhosin patch.

Using PHP 5.3 promised better performance, but i could not get it running without errors. Even patches did not help. So for this we have to wait for an official PHP 5.3 supporting release of magento.

Using FastCGI instead of including PHP into the webserver together with rewrite rules makes all static content delivered by a small webserver without any PHP involved at all.

The webserver itself should be kept as small as possible, but include mod_gzip. A big "feeled" perfomance factor is delivering content gzip'ed. Especially for users on slower connections this has the biggest benefit.

XCache is a must - none of the other measures have a greater impact. For magento 20MB memory for the cache is appropriate.

MySQL also can be compiled with the above options, but this has not the huge impact as it has for PHP.

Optimize MySQL settings. Disable the query-log and enable the query-cache. Especially the query-cache with 32MB helps for magento. Do not forget to adjust the buffers appropriate - magento uses InnoDB engine, so innodb_buffer_pool_size must be set to achieve a minimum of 98% hit rate, key_buffer_size is only for MyISAM and can be ignored for magento. Use innodb_plugin instaed of innobase - it has significant performance advantages and magento uses the innodb engine by default.

Conclusion: With the above settings, magento delivers most pages within a second - even on small virtual servers.