PHP – APC really improves response time

Checking Google Webmaster Tool Yesterday, I noticed a noticeable increase of my blogs response time – meaning slower loading of my pages. I have originally no plan of using my VPS as a production box so I don’t bother installing APC. Yesterday, I installed one and greatly improved server response time.

Installation

Being a Slackware box (nginx and php-fpm), I installed apc via SlackBuilds.org site using a tool called sbopkg. It installed quick but as soon as I restarted php-fpm, I don’t find APC from the installed extensions.

Digging deeper into the configuration, I’ve found out that you need to add a new config to your php.ini. Find the group of lines having this text: extension=, then add this line (I prefer adding to top since they seem to be arranged alphabetically).

; My added line
extension=apc.so
; The rest of the extensions
extension=bcmath.so
extension=bz2.so
extension=calendar.so
extension=ctype.so
extension=curl.so
...

After setting up the config, restart php-fpm and check if APC is really installed.

/etc/rc.d/rc.php-fpm restart
php -i | grep APC

Result

Overnight, I was able to gather a nice graph from New Relic about how the performance improved.

APC improved response time

Don’t forget to install APC on your websites as well. Enjoy and share.

This entry was posted in php and tagged , , . Bookmark the permalink.

Related Posts

Leave a Reply

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