Too Much PHP


When looking at the best ways to optimize a site for high traffic, you have to move away from the idea that every page in a site can be dynamic. Most sites don't need all their pages to be dynamic, but they are in order to enable simple functionality that could easily be substituted for something a little bit easier on the server.

There are instances where you want every page to be dynamic - messageboards or aggregation systems. But then there are those sites that are all php because there is a login/logout button on every page, or a dynamic ad system, or something similar. The problem with this kind of dynamic immeshment is that each page view must be parsed, and a single spider can fill up the cache of whatever acceleration platform you are using.

There are some acceleration platforms that will allow you to configure which pages are cached and which ones are not. This can help, but at the same time you want to minimize processing time associated with any given page.

The best solution, in my opinion, is to look for alternatives to your page-by-page dynamic desires. If it's a login/logout button that you want to change based on whether the user is logged in or out, make the change a javascript function and keep your normal pages as static html. If you are geotargetting advertisments, think about using an iframe rather than dynamically updating ad code on the pages.

There's no beating the delivery time of static files. You can look to higher speed platforms than apache such as lighttpd. If you need a high speed dynamic solution, consider programming your web services in C and attaching them to either apache or lighttpd as a module, or there are even a couple of web service specific platforms that you may want to look at.

You can always beef up your hardware to deal with performance issues, but you should really look at what tweaks you can make to your existing environment before looking at hardware. Most sites that I have analyzed could see at least a 50% performance boost by just working a little bit smarter. For some sites, the performance boost could be much more dramatic.



Too Much PHP Commentary