Friday, April 20, 2012

Optimizing LiveWhale

Over the past few months we have been using New Relic to monitor the performance of our primary servers. The stack traces and front end performance graphs have been extremely enlightening. I have been able to see the results of even the smallest performance tweaks within minutes which has had some unfortunate consequences. The chief of which I have become slightly obsessed with how things are running down to the millisecond. The good news is, since I am the Dev/Ops guy I can call it work and get paid for it. 

Our website is built on a small PHP CMS called LiveWhale. This particular CMS has some really great features like built in content caching, CSS and JS aggregation and a developing API. There are a few drawbacks as well one of which is it relies heavily on Apache specific configs, and has a few security holes(which are quite minor.) When my boss and I first began to focused our attention on improving the performance, we focused on fixing a few php errors we where previously unaware of and applying APC. It seemed though that our efforts really havent effected the overall performance of our application because most of our latency lies within Apache's network stack the transfer bandwidth and the browsers DOM rendering. 

My overall plan to improve the performance is to reduce Apache's response time by switching to mpm-worker, adding disk caching and work with our front end developer to squeeze down our included files and possibly reduce the DOM complexity.

Because LiveWhale relies on an Apache infrastructure, I really can't switch to a higher performing server like Nginx or Cherokee, but there are a few things that can be done. One is to switch the engine from mpm-prefork to mpm-worker and add a bit more static file caching. What I recently discovered (quite by accident) is, that in order to change to mpm-worker one must also use php with fastcgi. This is because the usual libapache2-mod-php package conflicts with the mpm-worker package. Another tweak I alluded to is to add server side file caching with apaches mod-disk-cache.

So switching to fastcgi is quite a good thing because it should be another performance improvement however it probably won't effect the overall php stack much since LiveWhale is already quite efficient. To accomplish the switch I did some reading and followed this blog post for the apache config parts.

No comments:

Post a Comment