Optimising Your Web Stack Performance for Magento
This is an old revision of the document!
Apache is a hugely popular web server (the A in LAMP). It can serve PHP sites using mod_php, FastCGI or CGI.
NginX is becoming an increasingly popular alternative to Apache and Lighttpd due to it’s stability, light weight and speed. NginX can server PHP sites using FastCGI or CGI.
* Set memory limit to 64M
PHP Opcode caches reduce the processing overhead involved in reading and compiling PHP scripts. They utilise shared memory as a way of storing and re-using compile scripts.
APC http://uk2.php.net/apc is a free PHP opcode cache written by the PHP team and packaged using PECL.
Most operating systems install a lightweight MySQL configuration by default, a good LAMP server should provide a decent amount of it’s resources to MySQL. Machines with multiple cores and over 2GB RAM need to be configured carefully to make sure available RAM and cores are being used efficiently.
There are some excellent tips in this Magento blog post http://www.magentocommerce.com/blog/comments/performance-is-key-notes-on-magentos-performance/
InnoDB (http://www.innodb.com/) is an alternative storage engine which makes use of MySQL’s client/server architecture. Whilst it shares some configuration settings with MyISAM (MySQL’s default storage engine) it has many settings of it’s own and will compete for server resources with MyISAM. It’s possible to tune MySQL server purely for InnoDB if no MyISAM tables are being used.
On larger sites MySQL’s replication functionality can be used to spread SELECT queries across multiple machines. Writes operations will still be run on every server in order to maintain data synchronisation.
Magento uses file caching to store often-used data in an easy to use format. The speed of file caching is directly dependent on speed of the filesystem on which the cache files are being read or written.
tmpfs is an in-memory filesystem designed to deliver the best possible performance.