New Azure CDN Features and Premium Service Released

Azure CDN is a global content delivery network for distributing content to local servers to improve latency and performance.  Azure CDN works with either a storage account or an Azure Web Site as the source of its cache and then uses HTTP headers to dictate how long content is cached within its network.

Microsoft has just released a new Azure CDN Premium service which provides additional fine grained rules for managing how content is cached.

In addition, Microsoft has added a key feature that was missing – the ability to purge content.  You can now go either through the Azure Portal or through the new CDN API and invalidate your CDN cache or individual URLs.

Microsoft has also rolled out new pop locations in India, Australia and South America.

Read More

Microsoft Partners with Akamai to Extend Reach of Azure CDN

The Azure Content Delivery Network is a service for caching and distributing content around the world.  For organizations with international traffic to their web site or applications, the Azure CDN pushes content such as video, images, pages or any other content to local nodes located closer to the end user to reduce latency and improve speed.

Here are the current locations of the Azure CDN nodes for distributing content around the world.

CDN POP Locations

Microsoft has just announced a partnership with Akamai to expand the Azure CDN network into Akamai’s CDN network.  Pricing has yet to be announced but Azure CDN will be moving to a two tier “Standard” and “Premium” model.

Akamai’s CDN platform already delivers 15-30% of the world’s web traffic through its massive network.  Akamai has more than 1000 node locations all over the world including South-America, Africa and the Middle East (which Microsoft currently has no presence).

Here is Akamai’s current network map – you can see that in particular in South America and

Read More

Azure CDN now Integrates with Azure Media Services

Azure CDN is Microsoft’s global content delivery network.  It has a set of local nodes around the world that provide faster local access to content around the world.  Azure CDN has supported content delivery of blob storage content (e.g. files) and Azure Web Sites.

Microsoft has just announced that Azure CDN will now support integration with Azure Media Services.  The CDN acts as a local cache for your video content as it is streamed to your audience around the world.  By moving content close to the user, performance and reliability of your streaming content is improved.

Blog1 CDN global map - storage to CDN to users.pdf-Manling-D

Read More

Testing Azure CDN Caching

This web site uses Azure CDN as a method to cache content (in addition to WordPress’ CDN).  I wanted to see how Azure CDN really makes a difference so I created a specific Azure CDN Performance Test to see how it impacts Azure Web Site Performance.

Creating an Azure Web Site and CDN

To test out our application, I created a new Azure Web Site called cachetest.  In addition, I created an Azure CDN end point based on this web site.  Note: it can take an hour for the Azure CDN to successfully cache all your content. 

Designing the Basic Test

I created a very basic web application using the ASP.NET MVC Framework (you can find the files on Github here).

The application displays a simple page that displays a random number and the current date/time.  In addition, it has a method called “SomeSlowOperation” which calculates prime numbers using a really bad algorithm from 1 to 100,000.  Running the page takes about 10-15 seconds under zero load and produces the following output.

image

Refreshing the page generates a new random number and updates the date that the page was constructed.

image

Adding Caching Settings

When you use Azure CDN, you have to make sure you are issuing HTTP Cache Control settings for both static content and dynamic content.

For static content, you can set the cache parameter in the web.config like this:

<system.webServer> <staticContent> <clientCache cacheControlMaxAge="1.00:00:00" cacheControlMode="UseMaxAge" /> </staticContent> <validation validateIntegratedModeConfiguration="false" /> <modules> <remove name="ApplicationInsightsWebTracking" /> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" /> </modules> </system.webServer>

This directive will mean any static content (e.g. scripts, CSS files, images, etc.) are cached by the Azure CDN for 1 day.

For dynamic content (e.g. our ASP.NET web page), you need to add HTTP CACHE directives into the page itself.  The easiest spot to put this is in the controller’s method like this:

public ActionResult CacheTest() { Response.AddHeader("Cache-Control", "public, max-age=900, s-maxage=900"); CacheTestModel cacheTestModel = new CacheTestModel(); ViewBag.Message = "Cache Testing Page."; return View(cacheTestModel); }

The Response.AddHeader method will add the Cache-Control directives that will be read by Azure CDN to dictate when to expire the page. 

NOTE: without these cache directives, Azure CDN caches content for 7 days and once cached there are no tools available to invalidate the cache!  Make sure you have the cache directives working before you start accessing the page through Azure CDN.

Running the Test

To run the test, we simply accessed the page through a regular browser through some test VMs running in Azure.  We also tested access through my local laptop in Toronto. 

The Results

Hitting the page directly without going through Azure CDN produces the expected result – each page load takes 10-15 seconds.  Hitting the same page once cached by Azure CDN takes milliseconds!  However, the results of my tests yield some interesting results in terms of when a page is actually cached:

  • It takes 3 hits to the same page before Azure CDN seems to cache the page.  The first two loads are slow and reload the page (you can tell because the random number and the dates change).  On the third load the page is now served from cache and is very quick (e.g. milliseconds) and the content is now the same on each load.
  • Caches seem to be isolated to particular locations.  For example, my browser running in Toronto is served cached content after 3 page loads but when I run the same page in a VM in North Central US, there is no cached content and it takes another 3 page loads before that location is serving cached content.
  • As a result of the local caches in different locations, the content that is cached can be different if it’s rendered dynamically.  For example, here are the results for my browser in Toronto vs. a VM running in the US.   Conversely, two VMs running in the same region had the same behavior, e.g. both were served the cached version of the page.  It’s not clear where the regions are located and their boundaries.

image  image

  • If query string is enabled, then each variation of query string follows the same rules as above, e.g. you need to load the exact same URL with the same query string three times before caching seems to take any effect.

Conclusions

Azure CDN will definitely take load off your web server, especially in cases where you have significantly complex or expensive page loads.  However, the caching behavior means that Azure CDN may not be caching as expected – each region has its own caching and pages are only cached after being repeatedly hit in the same region.

Once the page is cached, performance is a lot snappier especially for pages that take a long time to process.  Make sure you set your cache expiry to be as long as possible to maximize the value of the cache and avoid it being expired. 

Read More