Sep 30

Are your PHP webserver scripts consuming too many resources?

If you have a hard loaded webserver, with php scripts, you might consider optimizing the PHP setup before investing in more hardware.

Here are three tips for a production system, there are lot of other tweaks, but these three really makes a difference.

1. Use PHP5-fpm instead of fast-cgi, its balancing resources better and better to automatically recover after a crash.

2. Use APC cache. Avoid PHP generating opcode for each request, with the APC cache the opcode is cached, and retrieved from cache at each hits. It gives a dramatic performance boost.

3. Xdebug is very cpu intensive. Make sure you do not load xdebug in your php.ini. Its not sufficient to disable xdebug, you need to make sure it never loads. Below is an image of the cpu resources on one of our production systems before (xdebug loaded, but disabled) and after (xdebug never loaded). Its quite easy to spot when the change were implemented. It reduced cpu consumption from around average 180% to average 120%.


This entry was posted in php. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *