What is a CDN?

What is a CDN?


Jul 16, 2024
by frz
in DevOps

CDN stands for Content Delivery Network. It’s a quick and efficient way to deliver content from your website or application to the user by using their geographical location. It uses a network of servers across the world (also called POPs – ‘points of presence’). When the user requests information from a website using a CDN, they are automatically connected to the closer server (called ‘the edge server’), ensuring a fast and reliable online experience.

What’s the Difference between CDN and Web Host?

The CDN doesn’t host content per se and therefore won’t replace a proper web hosting solution. However, it ensures a much better website performance caching content at the network edge. Regardless of their web host, many websites struggle to find that hosting services meet their performance needs; meeting they often end up relying on CDNs to prevent interruptions in service and improve security.

Why/How to Use A CDN?

There are a number of use cases for CDNs, such as:

  • Delivering static resources from websites towards client applications: This is applicable for content that does not need to be modified by the server for each request and encompasses documents, files, images, HTML pages and fragments, client-side scripts, style sheets, and more. They become available to the CDN as the application creates items at runtimes – but it doesn’t do so for each request.
  • Delivering shared content and public static to devices: This is made possible by the application (which is a web-service itself) offering an API to clients running on devices such as mobile phones and tablet computers. The CDN can even deliver static datasets usable by clients and can be used, for example, to distribute JSON or XML documents.
  •  Serving websites with entirely public static content websites: This means there is no requirement for any dedicated computing resources.  
  • Streaming video files on demand: Through the global data centers that offer CDN connections, low latency, and reliable connectivity, enable video services. 
  • Improving the overall experience for users: This is a significant benefit for those geographically far from the data center hosting the application, who might’ve usually witnessed higher latency. Since most of the website’s content is typically static, using a CDN will maintain performance and increase user satisfaction without forcing you to deploy the application to multiple data centers.
  • Supporting Internet of Things (IoT) solutions: If the application had to distribute firmware updates to each device and appliance involved in an IoT solution, it could easily be overwhelmed.
  • Coping with demand surges: Many circumstances outside of your control can cause a peak in demand – for example, if a hardware company decides to release an operating system update, millions of users may wish to download in a short window of time. CDNs will allow this to go through without requiring the application to scale.

What are the Challenges Posed by CDNs?

Cacheability: There are still issues that traditional CDNs aren’t able to cope with. One of them is the rise of personalized content (often considered “dynamic” instead of static). In a recent Instapage survey, 74% of respondents admitted to feeling frustrated when a site wasn’t personalized. These trends are made even more important by the sharp increase in online purchases due to the Covid-19 pandemic and other reasons. Because CDNs can’t cache dynamic content such as local headlines, location-specific products, account information, changing inventory, etc., customers are faced with slower loading times. And businesses using CDNs witness their traffic going all the way back to the origin, which means that their infrastructure is more costly and includes the cost of egress data for all those responses.

 Visibility: While content served from the origin shows up in metrics right away, traditional CDN stats and logging take minutes, or even hours, to arrive – this makes them difficult to integrate.

Consistency: To maintain overall integrity, it is common that when one piece of content is updated, many others need to be fixed, changed, or even purged to avoid stale results. This complicates the use of CDNs.

Mixed content: There are cache-unfriendly technologies (think GraphQL) that rely on mixing large amounts of cacheable content with small notes of personalized content (for example, to build a shopping cart) – rendering the whole process uncacheable.

Navigation Issues: You need to be online in order to access CDN files – which makes it impossible to develop offline, have a problem with your internet connections, or work on the move. It’s also likely that you will need manual intervention or at least a build process when deploying your site to a live server since you will need to ‘CDN-ize’ local links to JavaScript libraries and other assets.

Files may not be optimized: Especially when using a modular library (like Modernizr or YUI), where CDN-hosted files are available yet usually come with large packages that can exceed several hundred Kb, making it a heavy importation. If you are looking for selective features, you could also merge all CSS and JavaScript files on your own personalized versions which will invoke fewer HTTP requests. This will create smaller files, quicker to download and easier to execute, especially on portable devices. If you are willing to increase the effort and cost put into the process, you could upload optimized files to a private CDN.

Lack Of Pre-caching Guarantees: Of course, a popular CDN file could be pre-cached, but this isn’t always the case, especially when working on a mobile device, as they tend to have small and relatively inefficient caches.

Blocked access: Even our globalized world has its boundaries, whether they be legal, commercial, political, or geographical. You may find yourself blocked from accessing organizations, or even whole countries, that have blocked the domain of many free CDN services. In the same way, large companies must adhere to local export laws (US ones for Google and Microsoft, which come with restrictions on the use of data in Cuba, Iran, North Korea, Sudan, and Syria; and this very list can change at any moment depending on governmental decisions).

Important Steps if You’re Planning on Using a CDN

  • Deployment. You must decide where the CDN will fetch the content from, which will indicate whether you need to deploy it in more than one storage system. Don’t forget to take into account that deploying static content and resources will have a particular process (you may need to implement separate or additional steps).
  • Versioning and cache-control. Think about how static content will be updated and how updates will be deployed. You should also master how caching works, understand how it is performed by the CDN, as well as the time-to-live (TTL).
  • Testing. While testing should be a key priority, remember that it can be arduous to test CDN settings locally when developing or within a staging environment.
  • Search engine optimization (SEO). Since static content is served from a different domain when you use the CDN, reflect on which effect this may have on SEO to avoid getting caught by surprise once products have gone live.
  • Content security. Since some CDNs don’t offer content access control, make sure you have a security plan in place before launch.
  • Client security. Clients may try to connect from a security-constrained environment that will limit their access to CDN resources or prevent them from loading resources from anything other than the origin page. You’ll need a fallback implementation to handle these situations.
  • Resilience. Make sure your CDN is resilient so it doesn’t become a single point of failure for an application or an entire system.

Remember that while traditional CDNs have many advantages, there may be cases in which using Content Network Delivery will be less useful. For example, if your content has a low hit rate, it could only be accessed a few times while it is valid (consult its time-to-live setting). Especially if the data is private, such as is the case for large enterprises and supply chain ecosystems.

Sources:

  1. Cloudflare. (n.d.). What is edge computing? Retrieved from https://www.cloudflare.com/learning/serverless/glossary/what-is-edge-computing/
  2. Statista. (2020). Online shopping due to the COVID-19 pandemic. Retrieved from https://instapage.com/blog/personalization-statistics