This article originally appeared in issue 232 of net magazine. It also appeared on their site, but as they moved domains and lost the content, I thought I'd post it on here. I hope you find this article useful!
Imagine if I told you that you could drastically increase the performance and speed of your website with one small simple change. Would you believe me?
The ability to make that change comes in the form of a Content Delivery Network (CDN). In short a CDN is a collection of web servers distributed across multiple locations around the world to deliver content more efficiently to users. The goal of a CDN is to serve content to end users with high availability and high performance. So what does this mean for us as developers and why should you use a CDN for your files?
The benefits of using a CDN extend far beyond just brilliant response times, using a CDN also reduces the amount of bandwidth and requests that is served from your website. You get all the benefits of caching, Gzipping and a wider network that reduces the amount of bandwidth that is consumed by your website. A CDN also increases the amount of files that a browser can download in parallel. Most browsers only allow you to download 3 or 4 files at a time from one domain. Using a CDN will allow the users browser to download more files in parallel, increasing their response times.
Okay, you’ve told me all the benefits, but surely only large companies can afford to use a Content Delivery Network? Nope, CDN technology is commercially available to all developers and it is really affordable. You'll pay only for the file storage space and outgoing bandwidth that you actually use. I use a CDN for this blog that receives a few thousand hits a month and I only pay around 30p a month.
The most important part that developers can play in enhancing the browsing experience for users is improving the speed and response times of our applications. At Yahoo! a test was conducted and the sites that moved static content off their application web servers and onto a CDN improved end-user response times by 20% or more. Now, you may not get this level of an improvement, but even a small increase that will ultimately save you money is worth it in my opinion.
Commercial Content Delivery Networks
In this article I aim to compare 3 of the market’s leading commercial CDNs; Amazon Cloudfront, Windows Azure CDN and Rackspace CDN. I will put these cloud products head to head on these key features: CDN response times, price and ease of use. Although I have only profiled three, there are still some other great CDNs out there worth looking into, check out - CacheFly, EdgeCast, GoGrid CDN and Google AppEngine.
The Testing Process
In order to compare the response times, I uploaded a small image (8Kb) and used this as a benchmark across all the CDNs. I also tested this across a period of a week at different times of the day and using different servers across the world - this included London, New York, Tokyo and Sydney. I noticed that the response times can vary wildly between fresh visits, so in order to get the most accurate picture I needed to get a lot of data. Response times are also all relative to your geographic location and internet connection.
It is important to remember that when testing for response times you need to use the non-cached version of the image. Some CDNs add an expiry header and simply refreshing your browser might give you the cached version instead of hitting the server to fetch the image again. By hitting CTRL-F5 in your browser, you will request a fresh version of the file.
Amazon is by far the most popular option out there when searching for a CDN. They have also been creating cloud services for many years and have built up a great set of products. I have been using Amazon Cloudfront for a few months now and so far it has been fast, cheap and relatively easy to set up. Again, much like most CDNs in the market today, they charge only for the content that you deliver through the network, and there's no monthly fee associated.
Prices compared with the rest of the CDN services are very competitive, and it seems that by default the cheapest storage solutions are both in the US and Europe. I do feel that setting up an Amazon Cloudfront solution was a little more difficult compared to the other CDNs. It seemed more for “developers” than junior webmasters. However, once setup it was easy to use and very efficient.
A downside that I noted about Amazon Cloudfront is that there isn’t native support for GZIP at the time of writing this article. It can be enabled using custom scripts, but it would be nice if were offered as part of the package. Customer service also isn’t included by default and you need to pay a bit in order to receive this service. This could make things tricky if you are a new developer starting out with Cloud tools.
Rackspace Cloud Files
Rackspace seems to be a bit of a darkhorse in the CDN department. Their pricing was really competitive (similar to Amazon’s Cloudfront) as well as simple to calculate and flexible. RackSpace uses the Akamai network as a base for its CDN service. Akamai has been around a long time and has a vast global network with servers deployed in 72 countries. Akamai is also the world leader in content distribution with 73,000 servers around the world, so by using this option you get all the benefits of a world class network without the costs.
The setup was easy and even included an online tool that I could use to upload files with. However, I did come across a great tool online called CyberDuck. This tool offers an FTP-esque file explorer that you can quickly connect to your Rackspace storage account. This tool can also be used with any Amazon storage account.
In contrast to Amazon, GZIP compression is automatically enabled for any static file that you upload, you automatically receive this feature. The client support for Rackspace also seems quite impressive, they offer permanent phone service for client queries.
Windows Azure CDN
Windows Azure is quite a newcomer to the CDN market. There has been a big marketing push recently by Microsoft to promote their Cloud Services. I think that they have done a great job in providing an easy to use service that is available to all languages, tools or framework. That’s right - all languages. If you are using Node.js, Java, PHP or .net you will be able to use the Windows Azure CDN. Microsoft have gone all out to make this an open cloud platform that is available to all developers.
I found the service really easy to setup with loads of great tutorials available on the Windows Azure website. I managed to get up and running in 15 minutes. There is also a free 90 day trial that allows you to test out the services before considering buying them - this is a great option.
In order to upload any files to the Azure CDN I found it a little less user friendly than expected. There weren’t many tools online that allowed me to simply upload files to my instance in a FTP-like manner. Every time I needed to publish my entire application in order to upload the files. I would like to have seen an open source tool that has been developed for the other services, but I hope that this will come in time. Overall, a great CDN that was really easy and fuss free to setup. I have to say that the documentation on the Windows Azure site was by far the best of the three.
Response Times (London)
Running a set of tests over a 7 day period, I was able to put together the average, fastest and slowest repsonse times for the different CDNs. While this test was a very simple test, it did allow me to get an average across the different CDNs. You may find that depending on your location and a number of factors, the response times that you receive vary wildly.
|CDN Name||Average Response (milliseconds)||Fastest Response (milliseconds)||Slowest Response (milliseconds)|
A 7 day comparison of CDN Response times
|CDN Name||Storage||Bandwidth Out|
|Rackspace CDN||7p / TB||0.18 GB|
|Amazon Cloudfront||0.030p / GB||0.12 Europe & N America - 0.19 Other (Both Variable)|
|Azure CDN||0.0153p /GB||0.08 Europe & N America - 0.13 Other (Both Variable)|
As you can see from the table above, there is very little between these three CDNs and all offered a superb service. However, if I were to choose a winner amongst the three, it would have to be Rackspace. The RackSpace CDN consistently offered the best response times, the customer support has been great and the price is very competitive.
It is really easy to get setup using a CDN and if you only made one change to your site today, serving your static files from a CDN would improve your site performance significantly. You could even have one CDN account that served loads of different websites that you work on. In this article, I reviewed a few different CDN services out there - but whichever one you do decide to go with - your users can only benefit from this change!
Add your comment