Blog Post

Microsoft Developer Community Blog
5 MIN READ

Azure on the Cheap - Azure Front Door caching vs Azure CDN

chilberto's avatar
chilberto
Iron Contributor
May 18, 2020

Azure on the Cheap posts focus on the architecture, techniques and technology in Azure that add considerable value without breaking the bank. This value is being measured in both the amount of effort taken to develop, provision, and maintain the resources, as well as the monthly charge for the resource. 

 

Previous posts:

 

Azure Front Door caching and Azure CDN

This Azure on the Cheap post takes a look at the Azure Front Door (AFD) caching feature and Azure CDN. Caching static website content is a common technique to both improving user experience as well as reducing the load on webservers by offloading the delivery of static content to a dedicated cache service. Caching services like Azure Front Door caching and Azure CDN, are optimized for hosting static content and most CDN services are globally distributed.

 

But how does Azure Front Door compare with Azure CDN?

 

Azure Front Door

Azure Front Door provides a caching feature that is literally at a click of a button:

Azure Front Door does support some configuration of how caching is handled.

Most common requirements are supported including support for a Rules Engine.

 

Azure CDN

Azure CDN is also a feature that can easily be enabled in an Azure Storage. For example, in the Blob service menu, the Azure CDN option is available.

This requires a new endpoint to be created.

Once the CDN endpoint is created, you can control aspects of the CDN such as the blob container Origin path, supported protocols, caching rules, and other optimizations.

 

This post illustrates how website caching can help the performance of the Azure On The Cheap website. In the previous post we illustrated how using Azure Front Door improves performance by directing global traffic to Azure Storage near the user. We will attempt to improve performance by using the Azure Front Door caching feature. 

 

Note: This is not an exhaustive comparison. It is encouraged that you conduct your own investigation as each solution has a different mix of requirements.

Scenario

This post builds upon the previous post's example by introducing a dynamic component: Azure Functions. In this example, AFD distributes a static website globally. The website is composed of a landing page containing a searchable table and three galleries. The landing page is built with DataTables.net and sourced from an Azure Function. The purpose was to combine static and dynamic content. An important thing to note is the url of the Azure Function is contained in a javascript file. To solve this, an additional step in the GitHub Actions to determine the correct file when deploying to the regional storage location. This is not optimal and a bit ugly. In a future post we will explore how to clean this up.

 

The three galleries contain the same content but the images are referenced differently:

  • The first gallery uses local files
  • The second uses files sourced from Azure storage
  • The third uses files sourced from Azure CDN

The images range from 11kb to 77kb in size.

 

The following illustrates the new project:

Azure Front Door is used to route traffic to a storage account in the closest region to the user. The static website contains a grid that uses retrieves data from an Azure Function running in the same region. 

 

JMeter

Our favorite load testing tool is being used again, Azure DevOps Load Testing. Please see this wiki article on getting started. Unfortunately, it is just a matter of time before this DevOps feature is no longer available. Until then we will continue to use it. Please comment if you have a cheap alternative!

 

The JMeter test was written to perform the following:

  • Navigate to the landing page
  • Make an API call to the Azure Function
  • Navigate to the gallery containing references to locally held images
  • Navigate to the gallery containing references to images stored in the same blob storage
  • Navigate to the gallery containing references to images from Azure CDN

The JMeter test was issued against a single datacenter to gauge the performance of the website with and without Azure Front Door caching enabled. The expectation would be without AFD caching the Azure CDN will be much faster as these should be sourced close. We also anticipate that the performance of the images sourced local to the static pages and the images sourced from storage should be relatively the same. This is because they are both being retrieved from the same blob storage account.

 

Without Azure Front Door caching enabled

Without caching enabled we can see a clear distinction between the images delivered from Azure CDN and the ones delivered from the storage account.

 

 

What is interesting is a performance difference between the images delivered from storage. The same file is sourced from the same Azure Storage blob account but one the Local Gallery is via AFD.

 

The test was then modified to introduce a new test that retrieved the files directly from storage and not through AFD.

The images retrieved through AFD do get a performance improvement just by using AFD. Nice.

 

With Azure Front Door caching enabled

But how does AFD with caching compare to Azure CDN? With AFD caching enabled, the same test is performed.

Both the images and the landing page received a healthy performance improvement with caching enabled. Though not a comprehensive test, the performance between Azure CDN and the AFD cache appear comparable. 

 

An interesting thing to note is when looking at the AFD metrics, we can see the point when caching was enabled.

This illustrates how using AFD with caching could be valuable in scenarios where content is being delivered from a webserver. 

 

Cost

So how does AFD with caching enabled and Azure CDN compare on cost? Comparing the cost of these two services is not really straight forward. AFD caching is a great feature and in many circumstances the simplicity of enabling this does makes sense. Once you begin adding additional features of Azure CDN like Rules, AFD does become more expensive as these are charged per ruleset. Comparing outbound data transfer pricing, Azure CDN is more cost effective.


Azure Front Door

 

In general, if your goal is to use AFD as a content delivery network, then Azure CDN makes more sense.

 

Summary

Though not an exhaustive comparison, this was a very useful exercise in exploring both Azure Front Door and Azure CDN. There are many ways of putting together cloud services and it is often not clear which combination is optimal. AFD is not a CDN but is much more. AFD can provide similar functionality but Azure CDN does just as good of a job at content delivery at a cheaper price!

 

Hopefully this series is useful (like if it is). As the solution includes additional functionality, we will continue to evolve the solution. Based on the findings in this post the next step is to change our static website to be delivered from Azure CDN and use AFD or Traffic Manager to route requests to the Azure Functions.

Updated May 18, 2020
Version 1.0
  • chilberto Nice comparison! Worthwhile to mention that one interesting feature offered by Azure CDN Verizon Premium only, is Token Authentication which prevents hotlinking, thus a risk of increased costs. I already had customers explicitly asking for this and for the time being, only Verizon Premium does offer it.

  • malecek's avatar
    malecek
    Copper Contributor

    chilberto, how is the CDN configured? From the screenshots it seems there is only one CDN endpoint called azureonthecheapcdn or azureonthecheap (the former in the endpoint creation dialog, the latter in the HTML snippet) which is backed by the UK instance of the storage account (called cheapstorageuk; judging from the endpoint creation dialog). The schema clearly shows three instances of the storage account and via color coding which is used by which visitors -- that part seems OK to me -- but does not show how it works with the CDN.

     

    If it is OK to have expensive cache miss, a single storage account may be used. Once the content is cached in the region by the CDN, further accesses are cache hits and thus practically independent from the location of the storage. It simplifies deployment of the website, too, as it has to be deployed just once, not three times (once to each storage), ensuring consistent deployment. Of course, it runs into the problem with Azure Function traffic distribution outlined in the Scenario section.

     

    If even the first load needs to be fast, the three Storage accounts are necessary, but how to set up the CDN endpoint? Front Door has backend pool, but CDN requires a single origin hostname. It feels Traffic Manager should be placed between the CDN and the Storage accounts to distribute the traffic. Traffic Manager was already announced as the solution the Azure Function traffic distribution problem.

     

    Looking forward to the next part of this series. Hope the lag is caused just by shifted priorities during the COVID-19 crisis and the third part of the series will eventually be published.

  • chilberto's avatar
    chilberto
    Iron Contributor

    Thanks for reading malecek and your comment. On each storage account, I enabled the CDN for the purposes of the test but as you point out the solution could be simplified if the initial cache miss is acceptable.

     

    Azure Front Door, Traffic Manager, and CDN functionality do overlap a bit. I feel it is hard to beat Azure CDN for a static website on a budget. For dynamic websites and existing websites, AFD makes sense especially if WAF capabilities are required, and the simplicity of caching static content. 

     

    The example scenario is basically a static website with dynamic content coming from Functions. Your suggestion of using a single CDN with Traffic Manager routing to the closest function does make a lot of sense. 

     

    Any suggestions for the next post in the series? I was thinking of a comparison of repositories: Table Storage, Cosmos, and SQL.