locked
Caching to improve Web Application RRS feed

  • Question

  • Hi,

    We are  trying to design an web app that talks to another server (physically separate)  via WCF to get the infomation. To get the good performance, we are planning to cache some of the data at web server. What are the best options that we have?

    Here are some of the things that we have been looking

    1. Enterprise Library 4.1 Caching application block
    2. Data base replication
    3. Sync Framework
    4. Web pages caching

    Could someone with enterprise design experience let us know which is the best way to do?

    Thank you,
    Suresh
    Thursday, June 11, 2009 5:52 PM

Answers

  • MemCached Win32
    Velocity
    .net Cache
    Enterprise Library Caching Application Block

    MemCached Win32: Up until recently I have used MemCached Win32.  This is a akin to a web farm (many servers serving the same content for high availability) but it is a cache farm.  This means that you can install it locally on your web server initially if you don't have the resources to go bigger.  Then as you go down the road you can scale horizontally (more servers) or vertically (more hardware).  This is a product that was ported from the original MemCached to work on Windows.  This product has been used extensively in very high traffic sites.  http://jehiah.cz/projects/memcached-win32/

    Velocity: This is Microsofts answer to products such as MemCached.  MemCached has been out for quite some time, Velocity is in CTP mode.  I must say that from what I have read so far this product will certainly turn my head once it is out.  But I can't bring myself to run big production projects on a CTP product with zero track record.  I have started playing with it though as once it gains momentum MemCached won't even compare for those locked in the windows world!  http://blogs.msdn.com/velocity/

    .NET Cache:  There is no reason to discount the standard .NET Cache.  It is built in and ready to use for free and with no (major) set up required.  It offers flexibility by way of offering mechanisms for storing items in local memory, a SINGLE state server, or a centralized database.  Where Velocity steps in is when you need more than a single state server (cache in memory) and don't want to use a slow database for holding your cache.

    Enterprise Application Block: I stay away from all of the Enterprise Application Blocks.  They are heavy frameworks that give more than I generally require!  As long as you remember to wrap everything that touches code that is not your own and follow simple rules for coding, stick to any of the other methods over this one!  (just my opinion of course - MySpace leverages as much as they can out of Enterprise Application Blocks!)

    You don't have to choose up front!  I generally create a cache wrapper that I communicate with in my code for methods such as Get, Set, Exists, Remove, ListKeys, etc.  This then points to an underlying level of cache abstraction that can point to MemCached, Velocity, or .NET cache.  I use StructureMap (or choose another IoC container) to inject which form of cache I want to use for a given environment.  In my local dev box I might use .NET cache in the session.  In production I generally use MemCached Win 32.  But regardless of how it is set up you can easily swap things around to try each system out to see what works best for you.  You just need to make sure that you application knows as little as possible about how things are cached!  Once this layer of abstraction is in place you can then do things such as run a compression algorithm (gzip) for all the data that is going in and out of cache which would allow you to store 10 times the amount of data in cache. - **transparently**.

    I cover .NET Cache, MemCached Win32, StructureMap, and the appropriate abstractions in my book if you are interested!

    ASP.NET 3.5 Social Networking (http://www.amazon.com/ASP-NET-3-5-Social-Networking-Enterprise-ready/dp/1847194788/ref=sr_1_1?ie=UTF8&s=books&qid=1225408005&sr=8-1 )

    Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net
    • Marked as answer by JakLucky Tuesday, June 23, 2009 6:57 PM
    Thursday, June 11, 2009 10:14 PM

All replies

  • MemCached Win32
    Velocity
    .net Cache
    Enterprise Library Caching Application Block

    MemCached Win32: Up until recently I have used MemCached Win32.  This is a akin to a web farm (many servers serving the same content for high availability) but it is a cache farm.  This means that you can install it locally on your web server initially if you don't have the resources to go bigger.  Then as you go down the road you can scale horizontally (more servers) or vertically (more hardware).  This is a product that was ported from the original MemCached to work on Windows.  This product has been used extensively in very high traffic sites.  http://jehiah.cz/projects/memcached-win32/

    Velocity: This is Microsofts answer to products such as MemCached.  MemCached has been out for quite some time, Velocity is in CTP mode.  I must say that from what I have read so far this product will certainly turn my head once it is out.  But I can't bring myself to run big production projects on a CTP product with zero track record.  I have started playing with it though as once it gains momentum MemCached won't even compare for those locked in the windows world!  http://blogs.msdn.com/velocity/

    .NET Cache:  There is no reason to discount the standard .NET Cache.  It is built in and ready to use for free and with no (major) set up required.  It offers flexibility by way of offering mechanisms for storing items in local memory, a SINGLE state server, or a centralized database.  Where Velocity steps in is when you need more than a single state server (cache in memory) and don't want to use a slow database for holding your cache.

    Enterprise Application Block: I stay away from all of the Enterprise Application Blocks.  They are heavy frameworks that give more than I generally require!  As long as you remember to wrap everything that touches code that is not your own and follow simple rules for coding, stick to any of the other methods over this one!  (just my opinion of course - MySpace leverages as much as they can out of Enterprise Application Blocks!)

    You don't have to choose up front!  I generally create a cache wrapper that I communicate with in my code for methods such as Get, Set, Exists, Remove, ListKeys, etc.  This then points to an underlying level of cache abstraction that can point to MemCached, Velocity, or .NET cache.  I use StructureMap (or choose another IoC container) to inject which form of cache I want to use for a given environment.  In my local dev box I might use .NET cache in the session.  In production I generally use MemCached Win 32.  But regardless of how it is set up you can easily swap things around to try each system out to see what works best for you.  You just need to make sure that you application knows as little as possible about how things are cached!  Once this layer of abstraction is in place you can then do things such as run a compression algorithm (gzip) for all the data that is going in and out of cache which would allow you to store 10 times the amount of data in cache. - **transparently**.

    I cover .NET Cache, MemCached Win32, StructureMap, and the appropriate abstractions in my book if you are interested!

    ASP.NET 3.5 Social Networking (http://www.amazon.com/ASP-NET-3-5-Social-Networking-Enterprise-ready/dp/1847194788/ref=sr_1_1?ie=UTF8&s=books&qid=1225408005&sr=8-1 )

    Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net
    • Marked as answer by JakLucky Tuesday, June 23, 2009 6:57 PM
    Thursday, June 11, 2009 10:14 PM
  • I agree with Andrew - just wanted to add that I have worked on projects that have used .net cache and the enterprise application blocks with success. 

    Also, I have been involved in projects that have moved some data from the database server to the web server as you are thinking of doing.  We used database replication to keep them synchronised. How you synchronise would depend on how volatile the data is?  In the projects I've been invloved in the data changed very infrequently as it was master data - probably less than weekly.

    However, one of the caching mechanisms Andrew mentions would give enough performance in most cases I think.

    Hope this helps.
    Pl mark as answer or helpful if you found this useful
    Friday, June 12, 2009 8:14 AM
  • Hi Andrew and G Moore,

    Sorry for the late reply. I was stuck with another project and didn't get time to look back the forum. Thank you very much for your answers. Can you give me some pointers for .NET Cache? I tried to google and did not get a good link for it.

    Thank you,
    Suresh

    Tuesday, June 23, 2009 6:57 PM
  • You have a couple of options at the moment.  You can use the internal .NET cache (http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx ) which comes out of the box with .NET.  However this is a single server implemenation and doesn't scale in the same way that a cache farm would.  For this reason I suggest using MemCached Win32 (many large sites use this with great success) or you can start to look at the new product out by Microsoft called Velocity here and here (still in beta).

    Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net
    Tuesday, June 23, 2009 7:02 PM
  • Hello Suresh
    I have covered some of Caching concerns through my blogs here
    http://www.infosysblogs.com/microsoft/2009/05/caching_controversy_1.html#more

    take a look, should help your decision making.
    Regards
    Sudhanshu
    Thursday, August 27, 2009 11:41 AM