Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppFabric Caching for large scale web sites

Our web application is deployed in a web farm (more than 20 servers). The site has a huge traffic (millions of page views per day). In the first release, this application is using EntLib's CacheManager (Entreprise application block caching). We call this "Local Server Cache". There are many benefits but we still have a major drawback : each server manage its own cache and acces to database (not distributed).

That's why we are trying to implement AppFabric caching feature in order to reduce database round trips. One of the major problem we have is data synchronisation :

  • with GetAndLock/PutAndUnLock (aka distributed lock) page response time is higly affected
  • with Get/Put + simple server side lock, we have so many requests with the local cache ; no benefits.

So what are caching stragegies for large scale web sites ?

Thanks,

like image 682
Cybermaxs Avatar asked May 18 '11 08:05

Cybermaxs


2 Answers

I would say cache read only data as much as possible. For this you can use AppFabric Caching Service. You can setup a cluster of let's say 5 cache servers. Then all of your 20 front-end servers would talk to this cache cluster to get cached data. You can also take advantage of keeping the most frequent data directly on front-end (local cache). For example our configuration is this:

  • front-end (16 machines) with LocalCache to store 150.000 most frequently used items
  • cache cluster (4 machines) with HighAvailability mode storing all data to cache
  • database (1 machine) with all the data

It gets more tricky for data that you want to update. Every time you introduce locks, your performance will suffer.

like image 96
David Pokluda Avatar answered Sep 21 '22 13:09

David Pokluda


As I'd mentioned on MSDN, immediate consistency is expensive. You have to accept some tradeoffs in consistency, or lay out a lot of cash to be immediately consistent. Using the isolated read/write model we discussed on MSDN, along with queues, probably provides you the best performance/consistency bang for the buck. Multiple tiers of cache as suggested by David are also excellent, depending on your overall architecture/design. Using your own local in-proc or localhosted cache implementation also offers a lot of value -- not a fan of AppFabric's OOTB local cache myself.

--ab

like image 27
andrewbadera Avatar answered Sep 25 '22 13:09

andrewbadera