Monday, May 18, 2009

I presented a talk at the Wellington and Auckland .NET user groups this month titled "Best Practices -  Caching". The goal of the talk was to discuss why we might need to add caching to our applications, and the way that we typically add it to each layer:

  • Client-side: reducing data flowing to the server, enable caching through expiry etc
  • ASP.NET: stashing data; page-level, fragment, IIS caching
  • Business layer: cache objects to avoid computation
  • Data layer: cache raw data from the database; identity maps
  • Database: reduce hits on disk

The difficult part when caching at any layer is invalidating the redundant data that is stored in the cache when the source data changes. It's easier depending on the type of the data:

  • Reference - shared reads (e.g. Catalog)
    • Easy to cache and distribute
  • Activity - exclusive write (e.g. Cart)
    • Can cache each user's data separately
  • Resource - shared, concurrency read/write, large number of transactions (e.g. Auction bid)
    • Caching is hard
    • DB is best source of data, with careful caching

The second half of the talk we looked at two caching technologies - memcached and Velocity.

The presentation: Caching.pdf 

Some links:

Kirk

Sunday, May 24, 2009 10:49:28 PM (New Zealand Standard Time, UTC+12:00)
Here's an interesting article I found from the Architecture Journal: Caching in the distributed environment http://msdn.microsoft.com/en-us/architecture/dd129907.aspx

Kirk
Comments are closed.