Speed up PHP with APC - Alternative PHP CacheWritten by Jacob Nicholson
In this article we'll discuss how you can speed up your PHP script executions by taking advantage of the APC (Alternative PHP Cache). With PHP APC setup on your server you can automatically have duplicate PHP script executions optimized to run more efficiently.
Because PHP is a dynamic scripting language every time there is a request for a page, instead of the server simply handing that file off to the website visitor requesting it, the server must first parse the PHP code in your script to generate the resulting HTML code to hand off to your visitor's web-browser. This is ideal for web pages that have content that is constantly updated, since each visitor is getting a fresh copy of the page. So for instance if you have your PHP script pulling down data from a database, as soon as there is new data in the database it will automatically be in the generated HTML code for the next visitor requesting that page.
However in most cases this constant need to re-run PHP scripts to get back data that hasn't changed can be taxing on the server. One way to help combat any possible problems with your PHP scripts consuming too many resources, and to help ensure that your website can handle a sudden flood of new visitors, is by implementing what's called opcode (operation code) caching for PHP.
APC for PHP is one of the most widely used PHP opcode caching solutions in use today, and APC is planned to be included in the next release of PHP 6 by default. You can utilize APC on a VPS (Virtual Private Server) or a dedicated server that is running PHP as either DSO or FastCGI. You might want to read about choosing the best PHP handler for your specific needs, and also a more in-depth explanation on what DSO and FastCGI are.
Our system administration department can setup APC on your server for you if this is something that you'd like to take advantage of. We will also be updating this article at a later date to include full instructions for installing APC yourself if you have root access on your server.