All

Deep Dive - What is a CDN and how does it work?

29 Apr 2022, by Slade Baylis

As internet access and adoption are rapidly increasing across the world, the number of online purchases is also climbing year after year.  With large parts of the world going through various types of lockdown over the last few years, this too has caused a significant jump in digital over physical sales.  Due to both of these factors, today it’s more likely than ever that traffic that comes to your website will be from global sources, rather than just local traffic.

With this development, there are specific hurdles that will need to be overcome.  Firstly, due to the distances between varied global audiences and your web hosting service, network latency issues can cause your website to underperform and load slowly.  Secondly, with increases in website traffic, another question that arises is how businesses should set up their hosting environment to cope with such increases?

One of the best solutions to both of these issues is to use a CDN service.

What is a CDN?

A CDN or Content Delivery Network is a service of which its primary aim is to efficiently deliver web content and increase performance by caching content closer to end-users.

Caching in this context refers to the practice of storing a copy of data or files in temporary storage so that they can be accessed faster next time.  For example, when your website is accessed, normally your web server goes to work and generates the website from your website code, and then hands that to the visitor that has requested it so that they can view your website.  This process requires a bit of processing power from the server, and can take some considerable time to complete. 

With caching in place, after that initial page has been generated by the server, when the next person requests the same information or webpage, instead of generating the page again, it just passes across the same response as it generated last time.  This means that the server doesn’t need to process as much information and the response can be much quicker than without caching.

The way that a CDN allows for caching content “closer to end-users” is by having a network of geographically distributed servers set up at key exchange points between different networks around the world.  These Internet Exchange Points (IXPs) are the locations where different internet providers, data centres, and web service providers connect in order to provide each other with access to their networks.  By having a presence and caching your content in these key locations, users not only get a cached version of that content, but they also get a faster response simply due to being closer to the server that is caching it!

As you can see from the image above, even though the origin server exists within Australia, the content from that server can be cached all around the world by the CDN. This allows visitors that are closer to those CDN servers to connect to and receive their cached copies instead.  As well as reducing the burden on the origin server, it also reduces things like latency from slowing down their browsing experience.  Latency can dramatically affect the load times of your websites or web-based applications, especially for global audiences. 

For example, when accessing a website, potentially hundreds of files can need to be downloaded for that website to display on your computer.  If you have a visitor that’s accessing your Australian website from the US, the distance between them and your web hosting server can cause a delay of up to 250 milliseconds per file – that latency could cause your website to load several seconds slower on their computer.  With research into online sales showing that a delay of a few seconds can cause people to abandon the purchase altogether, this can be a huge issue!

If you would like to know more about how latency can effect website load times, we’ve gone into some detail on this in our Slow Website? Your network could be the culprit article.

The key benefits of using a CDN

With the technical explanation out of the way, we come to the next questions:  What are the benefits of using a CDN and should you use one on your website?

To help answer these questions, here are the key advantages to using a CDN:

  1. Can improve website load times – Utilising a CDN can in some cases improve your website load times if your hosting provider’s servers are unoptimised or struggle to meet your website’s performance needs.  In addition, organisations that have global audiences can really benefit from caching content on servers that are physically closer to their end-users.
  2. Increased website redundancy – One of the primary benefits is the distribution of traffic over a larger number of CDN caching servers. This allows smaller organisations to benefit from a horizontally scaled system without needing to implement one within their own infrastructure.  As we’ve detailed in our recent Don’t be caught out – plan for infrastructure growth before it’s required article, a horizontally scaled system can be much more resilient and reliable than a single server solution.
  3. Increased capacity – In general, a single server solution with a CDN deployed in front of it will be able to receive a larger amount of traffic than a single server solution without one.  This is due to the CDN reducing the load placed on your origin server by serving static content from their cache instead.
  4. Reduced bandwidth costs – In addition to the points above, another benefit is the reduction in bandwidth costs on your origin server.  As the static content from your website is instead being provided by those caching servers, your origin server doesn’t need to send the same content repeatedly, saving on bandwidth costs.

With these advantages, you might get the impression that it might always be beneficial to set up a CDN in front of your website – unfortunately though, this is not always the case.

Limitations and misconceptions - Things to keep in mind before deciding to use one

When considering using a CDN, it’s important to not just know the advantages, but also to keep in mind some of the potential drawbacks or limitations on how useful they can be.

Static vs Dynamic Content

With regards to caching content, one of the limitations of a CDN is that only static content can be cached. “Static” content is content that doesn’t change over time as well as content that doesn't change based on who is accessing it.  For example, an image that’s used on your website would be a type of static content that can be cached, saving valuable bandwidth.  This type of content can be cached after one visitor has requested it, then cached for use with future requests from other visitors. 

However, an opposite example would be that of an eCommerce website.  With an eCommerce website, users are usually able to log into a unique account and see their contact information and previous order history.  As you can imagine, it would be a terrible idea to try and cache this information for displaying to other users, so this information would need to be fetched from the origin server every time it’s requested by a visitor.  This type of content is called “dynamic” content. 

When implementing caching or adding a CDN in front of your website, it’s important to consider your particular use case and what should and shouldn’t be included in that caching.

Website Speed & Website Hosting

One of the common reasons for a business wanting to use a CDN is the belief that doing so will speed up their website.  As we’ve touched on above, in some cases this is true and adding a CDN into your infrastructure may increase the performance of your website – though it’s not always the case. 

When you cache static content, that content from that point on will be requested from the CDN provider’s servers instead of your own hosting provider’s web server.  If your current hosting provider’s server is slow, unoptimised, or congested, then this may improve the website speed.  If, however, your audience is primarily in the same country as your website hosting server and that server is fast, optimised and has enough resources, it may in fact do the opposite.

This is why we recommend doing a website performance test both before and after enabling a CDN to get objective information about how it affected your website speed.  Remember to do a test from each country that you expect to receive traffic from!

“Free” doesn’t mean without cost

Though there are many “free” options for CDN services out there, they often come with unforeseen costs.

As free CDN services are provided without any charge, often they will set up the service in ways that save money rather than deliver performance.  For example, with free CDN plans it’s common practice to route all traffic internationally due to domestic transit being more expensive than international transit.  Having traffic routed internationally increases latency and will only slow your website for the majority of Australian traffic.

Any free CDN service is likely do this out of necessity to save on costs and keep the service viable.  This is why, if you’re looking to use a CDN with your own systems, we recommend looking for paid-for (but still affordable) CDN services instead.  These services don’t run into the same sort of cost-cutting issues that free alternatives necessarily have to implement.

Summary – Content Delivery Networks are useful tools that solve particular issues

From delivering content quickly to a global audience, to dealing with large influxes in traffic easily without being concerned about bandwidth usage or the stability of your web hosting server, Content Delivery Networks (CDN) can easily help you meet those challenges.  However, it’s important to note that no single approach is going to solve every problem, and that there are usually trade-offs that need to be taken into account. 

When setting up a CDN, your website speed may improve when accessing it internationally, but this may be at the cost of website speed domestically.  This is why we recommend performing speed tests of your websites, both before and after any change, to make sure that you’re aware of any changes in performance from the key locations your target audience is from.

With any sort of “free” service, it’s also a good idea to consider what short-cuts they have taken to provide that service.  In some cases, the service may compromise one aspect of a service in order to keep the service viable, which may be a deal-breaker for your particular needs.  In general, we recommended that you avoid “free” services for this reason, and instead sign up for paid plans instead.

Here at Micron21, we partner with Cloudflare and provide their Business and Enterprise plans to our clients – we recommend them highly to anyone who is looking to add a CDN into their infrastructure. 

Have any questions about CDNs or want to sign up to use one?

If you have any questions about how CDNs work or how you could go about setting one up in front of your website, simply reach out to us!  You can call us on 1300 769 972 (Option #1) or email us at sales@micron21.com

We’re more than happy to discuss the best options that will work for you and create a plan for getting it set up.

See it for yourself.

Australia’s first Tier IV Data Centre
in Melbourne!

Speak to our Australian based team.

24 hours a day, 7 days a week
1300 769 972

Sign up for the Micron21 Newsletter