Azure Content Delivery Networks(CDN)

 

Introduction

This post will explain to you what Azure CDN (Content Delivery Network). CDN is a server cluster geographically located in different regions to deliver the content of a website to users with the lowest network and transaction latency to deliver fastest contents.

(Image courtesy from internet) CDN global presence

When to use Azure CDN.

Almost each and every site has HTML, JS, CSS, image, video and font files that do not change much from user to user. To minimize the application load time we should use CDN.

CDN caches all static resources for a certain period of time by pulling them from the original server that it calls origin. After that any requests made by users for resources related to CDN are provided from this cached copy. When the cache expires, the resources are refreshed with re-requests to the origin.

A site consisting only of static content can easily serve over CDN.

How CDN works.

CDN can be configured from sources like an Azure App Service, Azure Cloud Service, Azure Storage account, or any publicly accessible web server.

CDN delivery working model
  1. Users can access the site by using URL and domain name (<endpoint>.azureedge.net) and it becomes a custom domain.
  2. When no cache is found in edge server Points of Presence (POP), POP requests files from the original server.
  3. The Original server returns the files to the POP of the edge server.
  4. The file will remain cached in POP for Time To Live (TTL) with default TTL is seven days.
  5. Other users also request for the same file by using the same URL, these requests will be delivered by the same POP.
  6. POP edge servers delivered from the cache files are faster and more responsive to user experience.

Let’s configure CDN for App Service, Configuration will be the same for Azure Cloud Service and Azure Storage account, CDN link might come under different menu section of Azure Portal.

How to Configure CDN for App Service.

Step 1 — Login to Azure Portal and create App service if you don’t have over the portal. In the App Service navigate the left hand side menu and go to Networking option as shown in the below image. We can see many options in this blade. We have to select Azure CDN and click on Configure Azure CDN for your app.

Azure CDN configuration under Networking.

Step 2 — After clicking we will navigate to Azure CDN Configuration form as shown in the below image. Hit create button to get Azure CDN endpoints.

Required fields for CDN configuration

Step 3 — We can see in below image endpoints are ready and configured with selected App Service.

CDN endpoint configured

Performance Observation with CDN.

As we can see above application will load time is 149ms without CDN configuration. After configuration of CDN we can see load time decrease to 76ms and Images and other static files are reading from Memory cache of POP edge server.

With CDN configuration

Advantage of Azure CDN

  • Better performance and improved user experience.
  • Decrease the load on Original server because files are delivered from the edge server (CDN).
  • Only configuration required to enable feature.
  • Robust and less maintenance.
  • Easy to configure and from resource only.

Disadvantage of Azure CDN

  • You need to spend around $0.10 per GB. It doesn’t seem much but comparing it with your regular hosting plan bandwidth, It is too costly.
  • Storing some sensitive files on the CDN network may open potential security vulnerabilities. Because, it does not matter what you store at CDN, it will be copied to all distributed servers.
  • Using CDN, you are creating additional “point of failure”. If the CDN network goes down you may lose website visibility.

Comments