Caching Data in Windows Azure

Windows Azure has separate data services for storing persistent data, including blobs and tables. However one thing that an architect needs to keep in mind, is that each call to this data is charged – hence, if there is certain data that gets called repeatedly, then it makes sense to cache that data either in the local instance disk or a shared cache so as to avoid repeatedly accessing the same object from the persistent datastore again and again.

There are two ways to do this –

1. You could decide to use the instance local storage. This is useful if you do not want to use the more expensive RAM for caching. The most simple way to do this is described in this post.

Note though, that this memory is available only for that instance, hence if the next request goes to another instance, the data call will be made again. None-the-less it can be useful if you have a limited number of instances, hence the cost of accessing data store multiple times is smaller than having a dedicated cache.

2. You could decide to use memcached or the Windows Azure caching service, and use this common cache to store this frequently accessed data. Memcached makes a lot of sense to people who are already used to using this in other platforms, and Steve explains how to do this very well in his blog. This approach is both faster (due to being in-memory) as well as more efficient when the number of instances is higher.

Designing applications to work in the cloud needs us to rethink how we store and access data, and how we use the resources available to us – since everything is metered, making efficient usage of existing resources will directly result in cost savings, eventually impacting the bottom-line.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax