Sam Says… Musings on Life, The Internet and Everything.

8Jan/12Off

The power of the CDN

Posted by Sam

As absolutely no-one on Earth will have noticed, this WordPress installation is entirely experimental. It's hosted on Rackspace Cloud on a fairly unremarkable Cloud Server. What makes it rather different to my day job is that this server runs NginX rather than Apache and is a little bit more groovy than most.

The first important question is "why NginX?", to which the answer would be that this is a 512MB Cloud Server (which indicates the amount of RAM) and simply couldn't handle a multi-user Blog installation under Apache and mod_php without significant performance tuning. NginX on the other hand is an extremely lightweight webserver which is perfectly suited to that scenario.

There are a few small challenges with NginX - namely that it doesn't "run" PHP or Python code - and I use those quite extensively. Instead, it provides the concept of backends - in my case I have some instances of PHP FastCGI Process Manager (php-fpm) to handle the PHP code, such as this WordPress installation and a custom spawn-fcgi implementation that spawns some instances of fcgiwrap to handle regular Python CGI binaries (I don't tend to knock up scripts using a full framework, so this implementation is a lot more lightweight than using the CGI server included in something like the Django or CherryPy application server frameworks.

And what that left me with was a WordPress installation that loaded on a fairly average DSL connection in less than 3 seconds. "Hooray!" you say, not bad for that hardware - but  I know we can do a lot better... which is where CDN's like Rackspace Cloud Files and a WordPress plugin called W3 Total Cache comes in. By pushing all of my media files into a CloudFiles Container, I can make a single view of this WordPress installation download one single file (index.php) from this Cloud Server and the rest comes from Cloud Files over the CDN.

Total load time now on that fairly average DSL connection: 550 - 750ms

Win!

Filed under: Internet