Edge Computing: An introduction to Content Delivery Networks

Published on: Sun Oct 23 2022

Series

Content

Introduction

Content Delivery Networks (CDNs) are technologies that helps to efficiently distribute and deliver data around the world.

Many popular website and applications (ie Netflix, Spotify, Reddit, Twitter etc 🤠) are most likely using a CDN.

Maybe you’ve developed an application that is content rich like a blog or a news site for a global audience — then there is a high likelihood that the site is using a CDN!

So, how does a CDN work ? 🤔

Before we talk about that, let’s first understand how a request works without a CDN.

In an infrastructure without a CDN, the request needs to go through multiple network hops to get to the server (ie data center) and then back to the client (the user).

Depending on the distance (between the client and the server), this can have drastic impact on the performance.

Directly accessing the data center from a different geographic location
Illustration of directly accessing the data center from a different geographic location

So, what is the limiting factor here ?

It’s the physical distance between the server and the client

This is because speed of light can travel only 299, 792, 458 meters per second (m/s).

Speed of light
Illustration: the speed of light

That means we are limited in how fast the data can be transferred.

The only other option is to reduce the physical distance between the client and server — That’s exactly what you can achieve when you use a CDN.

By introducing a CDN, we can strategically place servers that sit closer to the user, and these servers are referred to as “edge locations”.

This allows us to minimize the phyiscal distance between the data centers (ie servers) and the users (ie clients).

What you end up with is a network infrastructure that is optimized for global data distribution, and delivery!

accessing the data through the edge locations
Illustration of accessing the data through the edge locations

In the subsequent sections we’ll go through the following:

  • How it works
  • The type of assets
  • Use cases
  • Technologies
  • Edge compute (and stores)
  • Future implications

It may seem like the data magically appears at these edge locations but that is not the case.

There is a process that happens in order to make this possible, let’s go through that in more detail.

How it works

So, when you first introduce a CDN into your infrastructure, here is what happens.

The initial request is no different than any other request, it will still reach out to the origin server to retrieve the assets (ie html, js, images).

After the retrieval, these assets from the initial request can now be cached at these edge locations (if the CDN is configured to do so).

First request to the origin server
Illustration of the first request to the origin server

It is through this process that these assets become available at these edge locations.

Then, in the subsequent request, here is where the magic happens.

It can now reach out to the edge location first to retrieve the asset (cached version) before going to the origin server.

Subsequent request to the origin server
Illustration of the subsequent request to the origin server

Then when the cache expires, meaning the content is now stale, it will go through this whole process again.

Type of assets

Any type of assets that is served through the origin server can be accelerated and delivered through the CDN.

The assets include:

  • HTML pages
  • JS files
  • CSS files
  • Images
  • Videos
  • Files (PDF, Documents etc)
  • and other assets

Use cases

So, when would you leverage a CDN ?

As we already discussed, the typical application for CDNs are for content acceleration and delivery of static content to the global audience around the world.

However, CDNs are not just limited to this application.

There are many interesting ways you customize your infrastructure through the use of a CDN.

Let’s go through each of them.

Here are some areas that CDNs can be applied to:

  • Performance

  • Security

  • Personalization

Peformance

By leveraging these edge locations, the content delivery can be accelerated for the global audience.

The content is moved from the origin servers to these edge locations which results in a reduction in the response times (latency).

From an end user perspective, this means a better user experience (UX) while browsing the application.

Security

Using a CDN is not going to automatically improve security but it does provide capabilities that you can leverage to harden security.

Most of the time, the operators are responsible for adding the security features but some CDN services do provide out-of-the-box security capabilities (CAPTCHA, DDoS etc) that you can opt into (ie Cloudflare, Fastly, Akamai).

When you have a CDN, it acts like a gateway, the request will go through the CDN before it reaches the origin server. Which means, it can be used to manage of control the incoming and outgoing traffic.

Some of the applications may include:

  • Access management and control
  • DDoS prevention
  • Bot detection
  • TLS management
  • Managing security headers
  • and much more...

Personalization

Another use case for using a CDN is the ability to personalize the content delivery based on the location.

Here are some examples:

  • Providing an unique offering to a particular region (By Region)

  • A/B Testing or Feature Roll out by region (By Region)

  • Optimizing content and experience for a particular device (By a viewer device)

  • Alter content based on a particular region (By region)

  • and the list goes on...

Can’t you already do this through the server ?

Yes, but when personalizing at the edge there are additional benefits like:

  1. Performance - Faster content delivery

  2. Dynamic content - Leveraging compute at the edge, you can customize the response anyway you like (ie stitch content together from the edge cache and the origin)

personalizing request at the edge
Illustration of personalizing request at the edge using edge functions

Technologies

What are some of the available options if I want to include a CDN ? There are many options.

Here are some common managed services that provide CDNs as an offering:

  • Akamai Technologies
  • Amazon Cloudfront
  • Cloudflare CDNs
  • Google Cloud CDN
  • Azure CDN
  • Fastly
  • The list goes on...

There are many cloud vendors that provide this as a managed service (which is great)!

The capabilities of these services are quite similar but some vendors are doing some interesting innovation at the edge (ie Cloudflare with KV, R2).

If you are just using CDNs as a global cache, then any of these services should work! If you want more capabilities, then I recommend checking out Cloudflare.

Edge compute (and stores)

Sometimes the out of the box capabilities provided by these managed CDNs are not enough, and you need something more customized, what do you do then ?

Well, most of the managed CDNs provide the capabilities to have compute at the edge, also known as edge functions (or workers).

They allow you to extend the functionality of your edge servers so you can run business logic closer to the users.

Now if you combine this with an edge storage system like Akamai’s EdgeKV or Cloudflare’s KV or R2, you can start to do a lot of interesting things.

This means you can build some powerful applications that run closer to the users!

Future Implications

Most of the applications of edge computing are from CDNs through accelerating and distributing content globally.

However, I think there is a bigger trend here.

Directionally, what we are seeing is computing moving from a centralized model to distributed model.

Or said in a different way, more and more compute will take a hybrid approach between localized (edge compute) and global compute (centralized cloud).

Illustration of localized compute
Illustration of localized compute

As I mentioned in the this article, the main benefit of edge computing is the efficiency and performance.

Due to the geographic promixity of these compute servers, they are great for any sort of applications that require fast response times or real-time, near real-time capabilities.

That may make it great for compute on car or machine sensors, watches, or any other smart devices. This is just an example.

The localized compute can respond to computing needs at a more local level with efficiency, and it can also periodically check in with the global compute for any other relevant information.

These advantages become even more evident for applications in remote locations where connectivity is very limited or non-existent.

Conclusion

Before we part, let’s do a quick recap!

Takeways:

  • CDN is a technology that improves performance of the content delivery by moving servers closer to the user

  • The keys benefits of CDNs is the performance you get in the content delivery & distribution (Reducing the latency of the requests)

  • Beyond performance, other applications of CDNs include security and personalization

  • Type of assets include:

    • HTML
    • JS
    • CSS
    • Images
    • Videos
    • Documents
  • Edge compute (or edge functions) allow you to run business logic at these edge locations

  • Future compute may be divided into global and localized compute (Prediction)

    • Localized for performance and efficiency (Real time)

    • Global for centralization and syncing data or information

That’s it!

If you found this helpful or learned something new, please share this article with a friend or co-worker 🙏❤️ (Thanks!)


Enjoy the content ?

Then consider signing up to get notified when new content arrives!

Jerry Chang 2022. All rights reserved.