Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windsor Interceptors AOP & Caching

I'm considering using Castle Windsor's Interceptors to cache data for helping scale an asp.net site.

Does anyone have any thoughts/experience with doing this?

Minor clarification: My intention was to use Windsor to intercept 'expensive' calls and delegate to MemCacheD or Velocity (or another distributed cache) for the caching itself.

like image 344
Stacy A Avatar asked Sep 18 '08 16:09

Stacy A


3 Answers

Hey there, We've used Castle Windsor Interceptors, based on this article: http://www.davidhayden.com/blog/dave/archive/2007/03/14/CastleWindsorAOPPolicyInjectionApplicationBlock.aspx as well as the one mentioned above.

I found the whole thing pretty easy and it's a very elegant way to do AOP. However....

Careful with the performance though. Using interception creates a dynamic proxy that will definitely slow things down. Based on our benchmarks using a 500 Node computing farm we saw a performance decrease of about 30% by using interception in Windsor, this was outside what we were doing inside the interception as well (essentially logging method calls and params passed in to our methdods). and simply removing the interception sped the whole app up quite a bit.

Careful you don't make your expensive calls really expensive. :) If I were you I would look to cache at a different level, probably by implementing an IRepository type pattern and then backing that with various caching strategies where appropriate.

Good luck,

--
Matt.

like image 169
MrMattWright Avatar answered Sep 29 '22 16:09

MrMattWright


I've been using caching decorators (not interceptors) with Windsor and they work great.

Interceptors are good for this as well, see this for example.

like image 43
Mauricio Scheffer Avatar answered Sep 29 '22 17:09

Mauricio Scheffer


How are you implementing your data access? If your using NHibernate, I would suggest caching here. NHibernate comes with cache strategies for the .NET built-in cache, memcached (via NMemcachD) and Velocity. I've used memcached extensivly for enterprise level applications and have not had a problem with it.

An intercepter based caching mechanism is an interesting idea, one I haven't thought of before. It would be very easy to transparently apply. The one think I love about using the AOP features of Castle is because it's proxy based, you don't have to pollute your code with attributes.

like image 24
Chris Canal Avatar answered Sep 29 '22 17:09

Chris Canal