Sep
18
2008

Zendcon Day 2 – Scaling techniques

The “High performance PHP & MySQL scaling techniques” was given by Eli White and he showed a couple of need tricks to help you scale your website.

The simplest solution is adding a loadbalancer and a couple of PHP server for the frontend and a MySQL master with a couple of slaves for the backend. Remember, hardware is cheap! Another easy solution is installing APC (alternative PHP cache) because by default, PHP recompiles every request and by caching the compiled code you can save up to 50% in time. Interestingly enough APC will ship by default in future versions of PHP. The drawback is that in rare cases, APC can get confused by nested dynamical includes but as Eli said, if you do that you need to rewrite your code anyways.

Another clever tip was that you shouldn’t use a full blown apache+mod_php+etc server just to server static content. Use a lightweight server like thttpd to handle static content or have your loadbalancer cache static content so the request never even makes it to the webserver.

As far as dynamic content goes, you have three options (in general). Create everything dynamically on the fly, which is intensive and most of the times unneeded, pregenerate your content at set times (create all articles every 10 minutes) but this only works when your information can handle the delay. And the last option is to cache content, this is caching as you create and it’s exactly what smarty does.

Eli went on to memcached which has the huge advantage that it’s quick, and I mean lightning, also, the PHP extension provides for basic load distributing possibilities. The disadvantages are that you need to code the actual caching decisions yourself which can get tedious, also, you have to check for out of date and old data yourself.

The last thing before he went of into database partitioning which could be a book (and probably is) upons itself is using APC user variable. This is data stored on the local PHP server that is stored as native PHP datatype. The disadvantage is that the APC user variables are only available on the server where they are stored where memcached can be accessed by every server.

Written by admin in: zendcon08 | Tags:

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes