Back-End-Optimization - Best practice


I recently did a lot of front-end-optimization and followed a lot of the best practice guides which are available (Yahoo (Steve Souders), Google) on the internet or in books.

Independent from this - where I still have to optimize things - I am already thinking about the Back-End-Optimization. At the moment I am running my site on a VPS with CentOS 6.2, Apache 2.2 and PHP 5.3.

What should be the next step to optimize the back-end? Is there any best practice guide available with an order like Souders did in his book “High Performance Websites”? Should be the first step to switch from Apache to nginx?

First step is to measure where the bottlenecks are on the server.

APM tools like New Relic can help on this front but there are other routes e.g. query logs in MySQL, adding time-taken to Apache config, using xdebug’s profiler etc.

You also have to watch out for bottlenecks in the server before they get to the APM tools (depending on your scale). WebPagetest was originally running PHP on Apache but I was seeing some slow responses that weren’t showing up in any of the instrumentation - turned out I was running out of clients (insert giant rant about Apache + php + keep-alive here).

From a pure platform perspective, I can not recommend moving to Nginx + php-fpm + php-apc highly enough for serving PHP apps (won’t solve app-specific issues but is a huge deal for just being able to handle traffic)

Huge +1 for APM tools - I love New Relic and regularly go in and find some new hot code to optimize on WPT. It’s particularly fun when you first install it and get huge wins with minimal effort. I think in the first week I got the average response times down from ~200ms to < 20ms and things are hovering around 10ms right now (averages, measured on the server, lots of hand-waving there).

You can also get a (free) service to increase your response time.

I had Apache 2 + PHP + static cached files for my WordPress blog and got my load times to approx 1.5 seconds.

Then I configured CloudFlare to be in front of my website (I had to do a little DNS configuring) and my load times are now under 1 second on average.