PHP Optimization
Every now and then, you run into a situation where you have a large amount of code executing to create a complex page. This can lead to response times for web page requests that are not adequate for your client. Everyone should know by now that some basic coding standards and some simple caching can go a long way to prevent slow page load times. Sometimes, however, those simple steps are just not enough. Be sure that pages only load the code they require to display information. Also, be sure that you have set up some caching on your website (this also helps with heavy traffic loads). Another thing to remember: to find out where any bottlenecks might be hiding, it is important to run some benchmarks on your code. Sometimes a simple database call that might be executed multiple times on a page can be running very inefficiently and drastically affecting all of your load times.
One tool that can be useful is XDebug (which we previously talked about here). One thing not covered in our previous blog article is the ability to perform benchmark analysis on data captured with XDebug. Using a tool called WinCacheGrind, you can analyze the cachegrind profile file output by XDebug. This will allow you to target and eliminate or reduce functions that negatively impact your website’s performance. If you are hosting your site with Apache, another notable option is to set up Alternative PHP Cache (APC). You will need to verify all your website’s functionality is working properly with APC enabled. Our experience is that APC provides a great reduction in load times when configured properly.
Last but not least, be sure to think about performance when writing your code. There is a great article with 40 optimization tips over at reinholdweber.com. Click here to check out the optimization tips and feel free to comment with any other performance tools or tips you or your company have found useful.

November 11th, 2008 at 2:24 pm
You might also try optimizing the client-side. Yahoo’s “YSlow” extension for Firefox will tell you what you’re doing right, and what could be done better. http://developer.yahoo.com/yslow/