Azure Content Delivery Network

Azure Content Delivery Network

Speed up the delivery of web content by bringing it closer to where users are!

CDN is as simple as data is cached near your location, so when you request data, the request doesn't go along to the origin server where your data is stored. If the data you want is not present in the cache, then it will be fetched from the origin server. The biggest advantages of this service are high availability to the users and give super low latency which gives incredible performance from the end user's perspective. This is the basic idea behind the content delivery network. A CDN is a network of servers that can deliver web content to users quickly and efficiently. In this blog, we are going to do a practical and see use cases of how Azure CDN is being used in the real world. We are going to explore how Azure offers CDN service, but before that, we should get some more background on it.

The servers near your location where the data is cached are called edge servers or edge locations or point of presence locations (POP). Azure CDN offers a global solution for rapidly delivering high-bandwidth content to users by caching their content at strategically placed physical nodes across the world. User requests are distributed and served directly from edge servers so that less traffic gets sent to the origin server.

How Azure CDN works?

Let's understand it using an example

  1. A user requests a file/asset by using a URL with a special domain name, such as <endpoint name>.azureedge.net. The DNS routes the request to the best-performing POP location, which is usually the POP that is geographically closest to the user.

  2. If no edge servers in the POP have the file in their cache, the POP requests the file from the origin server. The origin server can be an Azure Web App, Azure Cloud Service, Azure Storage account, or any publicly accessible web server.

  3. The origin server returns the file to an edge server in the POP.

  4. An edge server in the POP caches the file and returns the file to the original requestor (Alice). The file remains cached on the edge server in the POP until the time-to-live (TTL) specified by its HTTP headers expires. If the origin server didn't specify a TTL, the default TTL is seven days.

  5. More users can then request the same file by using the same URL that Alice used and get directed to the same POP.

  6. If the TTL for the file hasn't expired, the POP edge server returns the file directly from the cache. This process results in a faster, more responsive user experience.

In India, there are four edge servers and they are located in Chennai, Hyderabad, Mumbai, and New Delhi. To see all the POP locations check out Azure CDN Coverage by metro

Before getting started with the hands-on you need to know some limitations that Azure CDN service has. Each Azure subscription has default limits for the following resources:

  • The number of CDN profiles created. A CDN profile is a collection of one or more CDN endpoints.

  • The number of endpoints created in a CDN profile.

  • The number of custom domains mapped to an endpoint.

Azure CDN features

Azure CDN offers the following key features:

  • Dynamic site acceleration

  • CDN caching rules

  • HTTPS custom domain support

  • Azure diagnostics logs

  • File compression

  • Geo-filtering

Quickstart Tutorial

Create a CDN profile

Sign into your Azure portal. If you don't have an Azure subscription, create an Azure free account before you begin.

Search for Front Door and CDN profiles.

Click on create. Choose between Azure Front Door and other offerings. Azure Front Door is a secure cloud CDN which provides the static and dynamic content acceleration, global load balancing, and protection of your apps, APIs, and websites with intelligent threat protection. Click on Explore other offerings and you will see 5 options. Each option provides specific services.

Azure Front Door Classic: uses Microsoft global network to provide dynamic application acceleration, load balancing, and security.

Azure CDN Standard from Microsoft (classic): A global content delivery network that uses Microsoft global network for content caching and acceleration.

Azure CDN Premium from Verizon: Verizon Media operates a global CDN platform with a focus on media streaming, delivery, and security.

Azure CDN Standard from Akamai: Akamai is one of the world's largest CDN providers with a large distributed network of servers around the world.

You can choose any offerings based on your requirements. As of now, we will choose Microsoft Classic because we just need content caching and acceleration.

Another point is deployment time for the Akamai tier is about one minute. The Microsoft tier takes about 10 minutes and the Verizon tiers take about 30 minutes.

In the basics tabs, do the settings as shown below

CDN profile is a global service, not a regional service. You can choose to change your pricing tier. In my case, I need a subscription upgrade to use Akamai CDN.

Keep the remaining tabs settings default if any, and create and deploy the resource.

The next thing we need to do is create an endpoint, it allows configuring content delivery behavior and access.

But while creating an endpoint we need to choose the origin hostname but we don't have any origin type as of now, basically, we need something to be cached right? It can be storage, storage static website, cloud service, web app, or a custom origin.

Create an Azure Storage Account

Let us create a storage account. Search Storage account and create one. Azure Storage is a Microsoft-managed service providing cloud storage that is highly available, secure, durable, scalable, and redundant. You should create all resources in the same resource group. In the networking tab, under network routing, you can choose between Microsoft network or internet routing. It determines how to route your traffic as it travels from the source to its Azure endpoint. Microsoft network routing is recommended for most customers. Keep default settings in other tabs and deploy.

Go to the storage account you created, in the left pane, under Data Storage click on Containers and create one.

By default the access level for the container is private. Click on the container and now you can upload binary large objects (blobs - storage option for any type of data that you want to store in a binary format) here. You can change the access level also. Change it to read access for blobs only otherwise we won't be able to access it through the web page. Azure blob storage is an object storage same as in AWS we have Simple Storage Service (S3) which is also an object storage.

I have uploaded the azurecdnimage.png and azurecdntxt.text

You can create a webpage accessing these blobs displayed on it, and it's optional for this practical. Go to each blob and copy its URL from properties by expanding the ellipsis.

<html>
    <body>
        <p> <b>Image and text file uploaded as blobs on Azure blob storage are accessed here through their URLs</b></p>
        <img src="https://cdnstorageblog.blob.core.windows.net/mycontainer/azurecdnimage.png" alt="image" width="700" height="300">
        <p><b>Text file is displayed in iframe</b></p>
        <iframe src="https://cdnstorageblog.blob.core.windows.net/mycontainer/azurecdntxt.txt" style="height:20% ;width:110%;" ></iframe>
    </body>   
</html>

Output:

Create an endpoint in the CDN profile

Now we are ready to create an endpoint in our CDN profile CDNprofile.

Select the origin hostname my storage account name is cdnstorageblog so it started with cdnstorageblog.blob.core.windows.net

The endpoint name is firstendpoint.azureedge.net

As I have mentioned before that each offering in Azure CDN takes some time to deploy, and I want to revisit that information with more clarity.

It takes time for the registration to propagate, and the endpoint isn't immediately available for use:

  • For Azure CDN Standard from Microsoft profiles, propagation usually completes in 10 minutes.

  • For Azure CDN Standard from Akamai profiles, propagation usually completes within one minute.

  • For Azure CDN Standard from Verizon and Azure CDN Premium from Verizon profiles, propagation usually completes within 90 minutes.

Now when those blobs will be accessed, the first time the request will go to the origin server in East US 2, then it will be cached into edge servers near me, I think it will be cached in Mumbai because it is the nearest location to me. But what if I want to test the performance, for instance, I want to know the time it takes to fetch blobs/data from the origin server and the time it takes from the edge server.

For that, we need to create a web application, more like a single-page web application, and access the blobs through it as we did before, but we have to check the performance with and without CDN.

Create a GitHub repo

We will use Azure Static Web app service to host the web app because we will need the web app URL to check the speed. But the source code for this web app will come from a GitHub repository, so create a new repo called cdnblogwebsite and create a folder named demo in that repo, and inside the demo create an HTML file named index.html.

Here is my repo: https://github.com/gayatri-bit/cdnblogwebsite

Create an Azure Static web app

Search for SWP in the Azure portal.

You should add your GitHub account here. The organization name will be your GitHub account name, choose the repository we created before and choose the main branch.

Select Custom in build presets. The App location and Output location will be ./demo as it is the folder in the repo.

And create the SWP. Click on browse. You will see something like this, it means you just have to wait for a few minutes so that Azure should get content updates.

After some time browse again and it will show the website

Check performance with and without CDN

Now Let's check the performance with CDN.

You can choose any website which checks website performance. I am using GTmetrix

Copy the web app URL, paste it, and check the performance.

The LCP is 665 ms. Largest Contentful Paint (LCP) is one of the three Core Web Vitals metrics, and it represents how quickly the main content of a web page is loaded. Specifically, LCP measures the time from when the user initiates loading the page until the largest image or text block is rendered within the viewport.

Go to your CDN profile, delete the endpoint, and now check the performance.

The LCP is 557ms i.e 108 ms less. These minute differences are very crucial in the real world.

List of Microsoft Azure CDN Customers

Companies using Microsoft Azure CDN for Content Delivery Networks include UnitedHealth Group Incorporated, a United States based Healthcare organization with 400000 employees and revenues of $322.13 billion, United Healthcare, a United States based Healthcare organization with 350000 employees and revenues of $285.27 billion, Microsoft Corporation, a United States based Professional Services organization with 221000 employees and revenues of $198.27 billion, Department of Agriculture, a United States based Government organization with 100000 employees and revenues of $151.00 billion, Ford Motor Company, a United States based Automotive organization with 183000 employees and revenues of $136.34 billion and many others.

Breakdown of Microsoft Azure CDN Customers by Industry (21 Verticals)

Breakdown of Microsoft Azure CDN Customers by Country

Use cases

The CDN benefits are essential for businesses ranging from small retailers to global technology service providers.

Netflix-grade video streaming

Digital media giants like Netflix and YouTube, are companies that already extensively leverage CDNs to produce a great video experience.

Mux works to help other publishers deliver high-quality video content by providing an integrated hosting/streaming/delivery bundle designed from the ground up to be developer friendly. Accessible through a single integrated API, Mux provides everything its clients need to offer premium quality video streaming services—and it depends on StackPath’s CDN to ensure high performance, complete parameter control, and a service that’s resilient and adaptable in the face of network disruptions.

With StackPath as a CDN provider, Mux meets and exceeds industry-leading performance standards while retaining full control over the content and reporting across a global network.

Fast and secure e-commerce

The personalized online jewelry retailer Safyre Labs (formerly Jewlr) provides an instructive example. This fast-growing company needed a CDN to ensure a seamless customer experience for 1,000 daily customers spread across North America, the UK, and Australia. Their initial platform relied on distributing assets directly from web servers, but this approach was no longer keeping pace with the rapid growth of their customer base.

StackPath’s CDN took on the responsibility of delivering assets across all local web domains and a separate checkout server. By positioning key assets like images, video, JavaScript, and CSS at the edge, StackPath’s CDN ensures a high-quality customer experience. The inclusion of a Web Application Firewall (WAF) helps simplify security administration, too. Safyre engineers don’t have to manage security settings for individual servers. And StackPath’s CDN analyzes incoming traffic for potential DDoS attacks, challenging incoming traffic if necessary to block threats to performance.

Optimized file delivery for emerging startups

Castos, a small startup that operates a podcast hosting platform for WordPress, is a great example of this. Castos began by acquiring an existing WordPress podcasting platform with a strong user base. They sought to monetize this popular plugin by offering integrated file storage and delivery. Podcasters could use this all-in-one solution to deliver their content without needing to manage a third-party storage/delivery solution.

Castos chose Amazon S3 as an origin server but understood from the outset that using a CDN would be essential for making this model work. The right CDN was needed to not only optimize podcast download speed and reliability but ensure a pricing model aligned with their business needs. As a startup with zero existing customers, Castos needed a CDN that would avoid pricing lock-in and upfront costs. They selected StackPath’s CDN which offers a flat-rate, pay-as-you-go pricing model, which is suiting them well as they now deliver over 165 terabytes of audio content each month.

Ultimately, StackPath’s CDN allowed Castos to avoid any cost overages, keeping their CDN spending closely tied to real revenue growth. And, with the seamless scalability of StackPath’s CDN, Castos has a smooth runway for continued global growth. Meanwhile, StackPath’s CDN utilizes an optimized network and peering strategy to minimize bandwidth costs—in this case reducing S3 egress charges by 30%.

I hope you guys now understand the importance and demand of CDN in today's world, from small-scale to large-scale companies use CDN for customer satisfaction.

That's all for this blog guys! Stay tuned for more Azure Networking Services Tutorials.

Azure Virtual Network

Azure Load Balancer

Azure DNS

Azure Application Gateway