Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance difference between Azure Redis cache and In-role cache for outputcaching

We are moving an asp.net site to Azure Web Role and Azure Sql Database. The site is using output cache and normal Cache[xxx] (i.e. HttpRuntime.Cache). These are now stored in the classic way in the web role instance memory.

The low hanging fruit is to first start using a distributed cache for output caching. I can use in-role cache, either as co-located or with a dedicated cache role, or Redis cache. Both have outputcache providers ready made.

Are there any performance differences between the two (thee with co-located/dedicated) cache methods?

One thing to consider is that will getting the page from Redis for every pageload on every server be faster or slower than composing the page from scratch one every server every 120 seconds but inbetween just getting it from local memory?

Which will scale better when we want to start caching our own data (i.e. pocos) in a distributed cache instead of HttpRuntime.Cache?

-Mathias

like image 569
Mathias Rönnlund Avatar asked Oct 10 '14 10:10

Mathias Rönnlund


1 Answers

Answering to your each question individually:

Are there any performance differences between the two (thee with co-located/dedicated) cache methods?

Definately co-located caching solution is faster than dedicated cache server, as in co-located/inproc solution request will be handled locally within the process where as dedicated cache solution will involve getting data over the network. However since data will be in-memory on cache server, getting will still be faster than getting from DB.

One thing to consider is that will getting the page from Redis for every pageload on every server be faster or slower than composing the page from scratch one every server every 120 seconds but inbetween just getting it from local memory?

It will depend on number of objects on page i.e. time taken to compose the page from scratch. Though getting from cache will involve network trip time but its mostly in fractions of a millisecond.

Which will scale better when we want to start caching our own data (i.e. pocos) in a distributed cache instead of HttpRuntime.Cache?

Since HttpRuntime.Cache is in-process caching, it is limited to single process's memory therefore it is not scalable. A distributed cache on the other hand is a scalable solution where you can always add more servers to increase cache space and throughput. Also out-proc nature of distributed cache solution makes it possible to access data cached by on application process to be used by any other process.

You can also look into NCache for Azure as a distributed caching solution. NCache is a native .Net distributed caching solution.

Following blog posts by Iqbal Khan will help you better understand the need of distributed cache for ASP.Net applications:

  • Improve ASP.NET Performance in Microsoft Azure with Output Cache
  • How to use a Distributed Cache for ASP.NET Output Cache

I hope this helps :-)

-Sameer

like image 194
Sameer Shah Avatar answered Oct 02 '22 03:10

Sameer Shah