Content Delivery Networks: Which one is right for you?

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?

Whenever a user makes a request to your website that is hosted in New York, and they are based in London, the internet "tubes" must connect from the user's location in London to the datacenter in New York. This means that your users will need to make a round trip across the world in order to retrieve a file from the server. Imagine not having to make a round trip in order to fetch these files - this is where a Content Delivery Network comes in. Since static files such as images, Javascript and CSS don’t change very often, there is no reason that they can’t be served to the user by another server that is geographically closer to them. It’s a shorter distance to travel and this means quicker response times.

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.

Performance gains

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.

Steve Souders originally coined the term “The Performance Golden Rule”, which states that developers should “optimize front-end performance first, that's where 80% or more of the end-user response time is spent.” Just think about all the static components that are in your webpages - images, Stylesheets, JavaScript, etc. If we can look to improve on the performance of these static files, we can make big gains in terms of users perception of our sites.

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 Cloudfront

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.

Amazon Cloudfront

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.

Rackspace Cloud Files

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.

Windows Azure CDN

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)
Rackspace CDN 18ms 8ms 47ms
Amazon Cloudfront 37ms 17ms 57ms
Azure CDN 17ms 8ms 59ms


A 7 day comparison of CDN Response times

7 day CDN performance comparison



Pricing

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)


Comparison

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.

Conclusion

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!








Comments

WIlliam V - 6/11/2014
Great article on the benefits of using a CDN. I just want to add that as websites become more complex (dynamic) whole site acceleration is critical for for optimal web performance. The three you are comparing primarily provides caching and does not accelerate non static web elements.

Vick - 9/25/2014
Thanks for the info. For me Edgecast is the network that i would consider for my websites. It's one of the leaders and a website's owner can be ensured that with it a site is fast, secured and well seo-optimized. Compare Amazon Cloudfront vs Edgecast http://jodihost.com/2014_edgecast_vs_amazon.php


Add your comment

300 Characters left


Please fill this in to confirm that you are human