Using a Content Delivery Network for Speed and Security

What is a CDN? Why do I want to use one?

A CDN is a distributed network of servers hosting copies of resources from your website such as to allow for an increase in speed of your website, and potentially aid website security.

The files held by a Content Delivery Network, such as MaxCDN the one we use here on SEOAndy, include image / photo files, video files, css files, jacasript files, font files and more. These are resources your website calls upon to load within the browser, though are not the data files (php, asp etc).

The files held in a CDN are duplicated across the globe on "edge servers". When a user connects to your website and requests a resource file they download that file from a CDN, thus calling only direct data from your server and files from a local "edge server". Below is a diagram showing this in action.

Benefits of Using a CDN

There are a number of advantages to using a CDN, here are just a few:

  1. Concurrent Loading of Resources Browsers are typically unable to load more than a given number of resources in parallel from a single domain. As a CDN works from another domain (or multiple domains) this issue is overcome, thus increasing load speed of your website making for a better overall user experience.
  2. Pre-Caching Saves More Time! Typically, websites such as SEOAndy, will call on a CDN for a specific file which is common around the web (for example jQuery from a Google cache). It is because many browsers will already have seen this file that it is cached on their browser and thus does not need downloading again, speeding up the website further.
  3. High-Capacity as Standard By their very nature a content delivery network is built to allow for a high-capacity of traffic across its servers for given file types. This optimisation means as long as your account has enough bandwidth with the CDN you can send as much traffic as you want at ANY time! In addition to this bandwidth with CDN's is usually very cheap.
  4. Distributed Data Centres By having data centres across the world, a CDN can offer the closest data centre to a user for their access to a resource, thus reducing the latency in loading and speeding up the website again. This also means that if a single data centre is hit by a DDOS attack and removed from service, or even during an update, then your site remains available through other centres.
  5. Security From Attacks Because your resources are hosted externally from your website itself you have some extended protection from DDOS attacks, such as the one SEOAndy recently recovered from. Keeping your website up longer and not annoying other sites on your web server, in theory. Finally, because CDNs are built for files and resources they are continually scanned for potential malware and protect you from this.

Downsides of Using a CDN...

For me there aren't many downsides to using a CDN, then main issue I've found is the setup of a CDN. Depending on the CDN depends on the setup, many CDN's will require some DNS change, though this is not the case for all.

One of the core reasons for choosing MaxCDN for SEOAndy is that it works with the plugin W3 Total Cache and does not require any DNS changes. It also works with CloudProxy which I've talked about as part of hardening wordpress.

The second downside is that it can be costly to add an SSL certificate too - this is even more the case if you are using proxy. However, this is not a huge issue and can be overcome by a developer.

The final downside is the a CDN is often misunderstood. Most website owners and developers believe that a CDN is a full copy of the website and that if your server breaks your site will remain live. This is NOT the case, if your server goes down your website will go down too.

Are CDN's Cost Effective?

There are many a web hosting offering huge amounts of bandwidth, but if your website becomes extremely popular then you may find yourself incuring a huge bill. In addition to this if your website is attacked and resources loaded millions of times, again you get hit with a bill for that traffic.

In most cases that bill will be huge in comparison to the low cost of using a CDN - my package on MaxCDN costs around £50 a month. Much cheaper than a potential bill for hundreds! In most cases the basic package of £6 a month would suffice.

An example is the use case of a Photographer who has a large portfolio, £6 a month to have your images load faster for users, to enhance their experience whilst protecting your website is a fraction of the cost of a single photo shoot.