If you have access-time logging enabled on any of your mysql, web server or cache partitions, try turning it off for a performance boost. If you’re using ext3 or reiserfs there may be faster journal write methods you can use. For more information see http://www.linux.com/feature/116693.
NginX is becoming an increasingly popular alternative to Apache and Lighttpd due to its stability, light weight and speed. NginX can server PHP sites using FastCGI or CGI.
* Set memory limit to 64M
mod_php for Apache is probably the most popular way to run PHP applications. There are a few down-sides to mod_php though: you’re forced to use Apache’s less efficient prefork MPM and your Apache processes will get large. Serving static files with 32MB+ Apache processes isn’t very efficient.
When PHP is run as a CGI program the web server spawns a process each time a request is made. This can be less efficient unless your operating system is good at spawning processes quickly. Unlike mod_php, CGI application won’t bloat your Apache, so the processes can remain small for service static files – important for high traffic sites.
When PHP is run as a FastCGI, a number of daemon processes are started and sit waiting for the web server to request them to run PHP code. This avoids the cost of spawning new processes each time in addition to not bloating web server processes. Due to the nature of long-running processes, FastCGI may require some periodic process maintenance. Lighttpd’s spawn-fgi script provides a method to limit the number of requests a single FCGI process is allowed to serve in an attempt to reduce the effect of memory leakage.
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. APC can be used with mod_php, FastCGI and CGI.
Most operating systems install a lightweight MySQL configuration by default, a good LAMP server should provide a decent amount of its 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.
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 its 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. Magento does however use MyISAM for some small tables so MyISAM is still required.
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. Again, since hard drives are slow moving this to RAM can really help. Having said that, operating systems will attempt to buffer reads/writes in memory in order to increase speed.
tmpfs is an in-memory filesystem designed to deliver the best possible performance.
Apache with mod_proxy using the worker MPM is a popular reverse proxy. There are probably also much leighter-weight alternatives. Setting up effect reverse proxies requires a good understanding of the application being proxied and the way in which it is used.
We implemented only MySql cache the page request come down to 1-2 sec. Its a huge difference without going for a higher end server