Question

Microsoft Enterprise Library 5.0 Integration Pack for Windows Azure

As far as I understand, cache will be stored in database, and all web roles are sharing same cache which is same as Azure's in-memory distributed caching.

I'm wondering anyone has successfully used Caching Application Block on Windows Azure instead of Azure Caching.

If so, how is the speed? Any noticeably different from Azure Caching.

Thank you for comments!

Was it helpful?

Solution

The caching application block is deprecated (see here). It is replaced by the System.RunTime.Caching namespace. However, SqlDependency is not supported by SQL Azure, so you cannot use the caching namespace either for a database-driven cache.

So your choices boil down to: implement your own local cache by reading from SQL Azure yourself, use Windows Azure cache, or simply read from SQL Azure on demand.

The performance will be much better with the local cache because it is... local :). A background thread (that you need to write) will refresh your cache on a specific frequency. So accessing the local cache will be going at memory access speed. But... it will not be synchronized perfectly across your Windows Azure nodes, because each node will have its own cache. To work around this issue, you could code your refresh logic in a way that it is done at the same time across all your nodes.

Reading from the Azure Cache will be slower than accessing the local cache, but all your Windows Azure nodes will have access to the same data at the same time. You still need to build a thread that will update the Windows Azure cache on a specific frequency; it won't refresh itself automatically.

Warning: keep in mind that Azure Cache works well if you know in advanced the key of your key/value pair cache entry. In other words, you have no way of getting the list of keys from the Azure Cache. For example, if you store a list of Zip Codes / Temperature, the zip code would be your key (which is a known set). So you could use the Azure Cache for this purpose. The Azure Cache was designed to help store ASP.NET session state, which also has a known key (the Session ID).

Finally, keeping your data in SQL Azure (or another store, like an Azure Table) may work very well too. However that depends on how much traffic you get and how many times you will read from the data source. Remember that in some cases building a caching mechanism is be more work than necessary.

OTHER TIPS

I am not very familiar with Enterprise Library. But Windows Azure Caching stores cache data in a remote server’s memory. When we request a cached data, we make a web request, and the server will return the data from its memory. If the cache server and our Windows Azure server are in the same data center (which is a recommended practice), the web transfer is extremely fast. If we use SQL Azure to store cached data, it takes about the same time for the data to transfer from SQL Azure server to our Windows Azure server. But it will take longer to query the data from the database compared to query the data from the cache server’s memory. SQL Azure may do some optimizations to increase data access, for example, cache the data in memory. But it is recommended you to use Windows Azure Cache over SQL Azure in this case.

Best Regards,

Ming Xu.

The Caching Application Block does not provide the features required for distributed caching. Instead, you should consider using one of the following technologies:

  • Windows Azure Caching. This enables you to provision a distributed cache in the cloud. For more information, see Windows Azure Caching Service.
  • Maintaining state and value in Windows Azure table storage. Examples of how to implement this, and other useful resources, are included in the Windows Azure Training Kit.
  • The caching mechanism of the System.Runtime.Caching namespace of .NET Framework 4.0. For more information, see System.Runtime.Caching Namespace.

The SQL Scripts which are compatible with the SQL Azure and are required for the Caching Database provider are available as a separate download. To get the scripts, download the EnterpriseLibraryIntegrationPack-WindowsAzure-sqlscripts.exe from the Microsoft Enterprise Library 5.0 Integration Pack for Windows Azure.

For information on using other classic Enterprise Library blocks in Windows Azure applications, see this white paper.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top