Does it overcome limitation encountered with HttpContext.Current.Cache?

Topics: User Forum
Sep 25, 2008 at 11:07 AM
Hi, Shared Cache sounds quite impressive from what I've read so far - nice work!

I've encountered a problem with ASP.NET's HttpContext.Current.Cache when I try to store objects over a certain size. See this thread for more detail - http://forums.asp.net/t/1182258.aspx. I'm curious if using Shared Cache may help me overcome this encountered limitation?

Cheers, Gavin.
Coordinator
Sep 25, 2008 at 5:20 PM
hi gavin,

sharedcache is a complete different process on your system. to use shared cache in replication or distributed mode makes sense in 2 cases:
 - you have more then one machine and you like / need to use the same cache for all of them 
 - you like to cache that many object that your application is getting recycled all the time

in general you can use both caches (asp.net & shared cache) side by side without any limitations - usually I have a wrapper class for that.

shared cache is a different process then iis and therefore you have no limitations.

may you can share with us a little bit more about your env., application and requirements. it will make it easier to give you  a specific answer.

you can add to sharedcache any size of objects but as bigger they are as slower it is because you transfer data from one into another process. in general there are no limitations about object sizes but they have to be serializeable (must!)    

regards,
roni
Sep 26, 2008 at 2:03 AM
Hi Roni,

Thanks for your input - it's much appreciated.

Our setup is currently 4 x Win 2003 servers each with one CPU and 2 GB RAM each (these are virtual servers rather than physical servers):
1 x Web Server
1 x SQL Server master database
2 x SQL Server readonly database (replicated from master)

Only the web server has memory we want to spare at present, as SQL Server is our bottleneck at present so we don't want to put more load there. We do hope to drop more web servers in to the mix in the future and it sounds an excellent idea to share the cache as we have many objects we'd like to maintain in the cache. We have a hell of a lot of content so I suspect the cache is getting recycled more often than we'd like. I've currently just dropped in some logging code so I can see how the cache is being used so will be able to make some educated guesses after the weekend.

All objects we wish to cache are serializable. And an example of the object we had issues with ASP.NET native caching can be seen here - http://forums.asp.net/t/1182258.aspx#2579745. I should imagine the speed of retrieving large objects from Shared Cache would be substantially faster than retrieving them from SQL Server? (especially if it's results for popular searches which query a lot of tables)

Cheers,
Gavin.

Coordinator
Sep 27, 2008 at 10:24 AM
Hi Gavin,

did you ever tried to used: http://aspalliance.com/CacheManager/Default.aspx ?

Its very easy to integrate this into running applicatoins and it gives you an idea how much momery do you use upon certain time. if i take your dataset from your provided link, then i get a size approx. of 15kb. loading data from sql server takes something around 30 - 90 ms - always depends on object size and hardware shared cache is much faster then that. you can easly test this with provided test application -> use option 200.

may i can ask whats the name of your website?

regards,
roni  
Sep 30, 2008 at 2:51 AM
Hi Roni,

Thanks for the CacheManager heads up - I'd never come across the tool before. Interesting to play with and useful to see how much memory is left. I'm actually based in New Zealand and most of our traffic comes from Europe so I'll need to pull an all-nighter soon and see how the memory is affected by peak traffic.

I've actually been logging all cache interaction over the weekend and have now analysed the logs... I was pleasantly surprised to see that cache is probably 99.999% staying persisted for it's full lifetime of 10 mins so I'll be looking at increasing the lifetime now. So my fears of so much content spreading cache memory too thinly seems unfounded at this point in time (I think it helps that I don't create new cache items when a crawler/bot is detected). A good percentage of our traffic is driven by online ads so their landing pages are definately benefiting from the caching. From these findings I'm thinking this site is probably not going to benefit from introducing Shared Cache just yet until we grow a bit more?

I think if I can come up with a solution to the caching data problem mentioned previoulsy this will help a lot. That particular data item (http://forums.asp.net/t/1182258.aspx#2579745) has very few variables from page to page so is likely to be the item which would benefit the most from caching and reap the most rewards.

Cheers again for all your input!
Gavin.

P.S. As for the website in question... sorry about the paranoia, but I don't like to expose too much about it's architecture alongside it's name (it already gets enough attacks as it is). However if you look at my profile on this site and click on to my portfolio you'll see the site at the top of the list at this moment in time if you're curious.


Sep 30, 2008 at 9:38 AM
Just in case you're interested... I found a work-around to my problematic caching object issue - http://forums.asp.net/p/1182258/2653828.aspx#2653828