2

By caching we basically mean, replicating data for faster access. For example -

  • Store freqeuently used data, from DB into memory.
  • Store static conents of Web page in the client browser.

Cloud hosting already uses closest DataCenter (CDN) to serve contents to the user. My question is, how does Caching Service makes it faster.

Abhijeet
  • 13,562
  • 26
  • 94
  • 175

2 Answers2

1

CDN is used to improve the delivery performance between your service datacenter and your customer, by introducing a transparent proxy datacenter that is nearer your customer. The CDN typically is set up to cache - such that requests from different customers can be serviced by the same "CDN answer" without calling the origin service datacenter. This configuration is predominantly used to offload requests for shared assets such as jpegs, javascript etc.

Azure Caching Service is employed behind your service, within your service datacenter. Unlike the built in ASP.NET cache, Azure Cache runs as a seperate service, and can be shared between servers/services. Generally your service would use this to store cross-session or expensive-to-create information - e.g. query results from a database. You're trading:

  • value of memory to cache the item (time/money)
  • cost (time/money) of creation of the item
  • number of times you'd expect to reuse the item.
  • "freshness" of information

For example you might use the memory cache to reduce the number of times that you query Azure Table, because you expect to reuse the same information multiple times, the latency to perform the query is high, and you can live with information potentially being "stale". Doing so would, save you money, and improve the overall performance of your system.

You'd typically "layer" the out-of-process Azure Cache with on-machine/in-process cache, such that for frequent queries you pull information as follows:

  1. best - look first in local/on-box cache
  2. better - look in off-box Azure Service Cache, then load local cache with result
  3. good - make a call/query to expensive resource, load Azure Cache and local cache with result
stephbu
  • 5,072
  • 26
  • 42
  • Hi stephbu, Thanks. Agree with you. Your answer is in line with my initial understanding. But `this link` says, https://www.windowsazure.com/en-us/home/features/caching/ `Windows Azure Caching delivers data closer to application logic`. How does this work? – Abhijeet Oct 21 '12 at 20:33
  • Marketing speak :( I guess there is a thin argument that both are caches, and that you could twist the cache request into "Cache Service delivers". They're trying to make two somewhat orthogonal systems appear under the same umbrella of caching for a feature checklist. It works as I prescribed. – stephbu Oct 21 '12 at 22:59
1

Before saying anything I wanted to point you to this (very similar discussion): Is it better to use Cache or CDN?

Having said that, this is how CDN and Caching can improve your website's performance.

CDN: This service helps you stay "closed" to your end user. Wit CDN, your websites content will be spread over a system of servers, each in its own location. Every server will hold a redundant copy of your site. When accessed by visitor, the CDN system will identify his/hers location and serve the content from the closest server (also called POP or Proxy).

For example: When visited from Australia your be server by Australian server. When visited from US you'll be server by US server and etc...

CDN will me most useful is your website operated outside of its immediate locale. (i.e. CDN will not help you is your website promotes a local locksmith service that only has visitors from your city. As long as your original servers are sitting near by...)

Also, the overall coverage is unimportant. You just need to make sure that the network covers all locations relevant to you day-2-day operations.

Cache: Provides faster access to your static or/and commonly used content objects. For example, if you have an image on your home page, and that image is downloaded again and again (and again) by all visitor, you should Cache it, so that returning visitor will already have it stored in his/hers PC (in browser Cache). This will save time, because local ressourses will load fasted and also save you bandwidth - because the image will load from visitor's computer and not from your server.

CDN and Caching are often combined, because this setup allows your to store Cache on the CDN network.

Also, this dual setup can also help improve Caching efficiency - For example it can help with dynamic Caching by introducing smart algorithms into the "top" CDN layer.

Here is more information about Dynamic Caching (also good introduction to HTTP Caching directives)

As you might already know, from reading the above mention post, no one method is better and they are at their best, when combined.

Hope this answers it

GL

Community
  • 1
  • 1
Igal Zeifman
  • 1,146
  • 7
  • 8