3
votes

I have a simple project that I'd like to publish to Azure Web Sites. I need to do some basic caching of a few values to speed things up a bit.

What's the right strategy for caching data in this scenario? I guess that as long as I stay on free or reserved I can use simple standard web cache as it's a single machine, but what happens if I'd like to use shared a number of instances? Is distributed cache really available for web sites? What other options do I have for simple cache here?

2

2 Answers

1
votes

According to this, it doesn't look like you could use the shared / distributed cache. Has that changed? Do you have a link that says Azure supports either of their 2 cache scenarios for websites?

As long as you only have 1 instance, you are right, using the normal outputCache should be okay. If you scale out to 2 or more instances, you may have to migrate from a Website to a Hosted Service in order to use either of the other 2 caching strategies. Azure has not been offering the full suite of features with websites that they do with hosted services.

1
votes

Here is my 2 cents based on a brief discussion under Dan's answer. As of July 2013, I've just deployed my web site / web application to Azure. It is kind of football (soccer for our US friends :-) ) prediction game. It is using caching in a way of storing lot of POCO objects (like list of matches, list of players, etc) in cache. It's not a brand new app, we ran it for 2 seasons on a on-premise hw (2 servers in a farm which imho was bit overkill, SQL db). Right now we are running on a single instance in shared mode. The new season is starting next week and should we see that single instance is not enough, we are prepared to scale up.

So I'm finally getting to cache. We opted for shared cache. How to set it up is well documented, although my personal feeling is that documentation is not keeping pace with how fast Azure evolve.

To put items to and from shared cache is dead easy as well as how to configure it in web.config. We had to put a little bit of effort into finding a way how to wipe out entire cache from your app when you need it - as far as I know, there is no way how to enumerate thru items already in cache. At the end, we ended up with a very simple solution, whenever you put anything into cache, you just note the key somewhere aside and when you need to wipe out whole cache, you use this.

Now, I have to say I'm not the person who pays the bill for this Azure hosting, I do not see current bill on Azure portal but I'm obviously concerned about overall price. What is not really clear to me is cost for using Shared Cache. It took me some time to find out some pricing table though I'm not entirely sure whether it really apply or not. I was not able to see this in Azure Price Calculator.

Going back to my comment under Dan's answer - I do believe there is a lot of developers working on small to mid-sized websites, using standard HttpCache as a place to put your POCO objects for faster access. In such examples, overall cache size might be up to 50 MB (obviously depending on a way you are working with cache). Such web sites might be OK on a single instance, but hey - 2 and more instances kick ass and I want to be ready when time comes to scale up. For such cases, I'm missing clear guidance on what kind of caching to choose and how much it will cost.