Ticket (Solved)

Azure and Orchard - which Cache Modules to use?

Hi all, I have recently started to use Azure with Orchard and have found the performance to be less than adequate. So in the attempt to improve website speed, I was hoping if anyone could enlighten me as to which of the following performance Modules I should enable and a quick synopsis of what they do […other than caching previously requested data]?

Performance > 
    Database Output Cache, 
    File System Output Cache,
    Microsoft Azure Database Cache 
    Microsoft Azure Output Cache 
    Output Cache 
    Redis Cache 
    Redis Output Cache 

One would gather that I should enable the two Azure modules, but without knowing exactly what they do - I'm a little hesitant. Thanks in advance, Pug

Re: Azure and Orchard - which Cache Modules to use?

Did you profile it in order to determine if caching would actually help?

Friday, September 9, 2016 7:43:24 AM bybleroy
  • bleroy
  • Lv. 08 Rookie
  • Total EXP: 527

Re: Azure and Orchard - which Cache Modules to use?

Here as i remember, so not sure for all details.

There is the regular CacheManager (commonly used by Orchard) which uses in-memory objects, a cached item can be removed on date, file change, signal. Orchard.Caching cache data in an extensible way by using an ICacheStorageProvider, so you can use your own provider or use a module that provide a custom one (see below). The default uses System.Runtime.Caching.MemoryCache (here an entry can be removed on memory stress).

Orchard.Redis is when you need to be synchronized e.g across multi nodes on a web farm ... Here you need a redis instance, add a connection string to the web.config ... Then, if you enable Orchard.Redis.Caching, Orchard.Caching will use the RedisCacheStorageProvider in place of MemoryCache. See in the related source file how the DefaultCacheStorageProvider feature is suppressed.

Orchard.OutputCache uses by default System.Web.Caching.Cache grabbed from HttpContext ... Here also, to be synchronized (e.g on a web farm) you can use Orchard.Redis and enable Orchard.Redis.OutputCache, then Orchard.OutputCache will use RedisOutputCacheStorageProvider.

If you run multi instances for an azure website, to get synchronized i think you can use Orchard.OutputCache.FileSystem, then Orchard.OutputCache will store data in the shared file system. Idem with Orchard.OutputCache.Database but by using your database.

SysCache is the NHibernate 2nd level caching, it reduces the number of database queries but i've heard of some synchronization drawbacks, maybe only if you use the admin. I don't use it but you can try it in production.

Never used Orchard.Azure.DatabaseCache but, as seen in the Module.txt, it configures NHibernate 2nd level cache to use Microsoft Azure Cache. Never used Orchard.Azure.OutputCache but, as seen in the Module.txt, Orchard.OutputCache will use Windows Azure Cache. I think these azure caches are distributed memory caches (so useful if you run multi instances). But it seems that these services will be removed, and the recommendation is to use Azure Redis Cache.

Personaly i use only one instance (that can be scaled up) per azure website, i only use the regular CacheManager and Orchard.OutputCache, a SQL azure database (not sqlce), and a keepAlive module to prevent from recycling (not needed in some azure website service plans).

Note: When running multiple instances it is recommended to disable the SessionConfigurationCache and ShellDescriptorCache components through the self documented HostComponents.config file, e.g to prevent some concurent file writtings (mappings.bin, cache.dat).

Note: For performance, maybe not an issue now, but because of a filesystem watcher issue on azure, i remember i also needed to prevent dynamic compilation. This by publishing precompiled modules (without sources and project files) and / or disabling in HostComponents.config the DynamicExtensionLoader and DefaultProjectFileParser components (maybe other components, i don't remember).


Tuesday, September 13, 2016 5:25:26 AM byjtkech
  • jtkech
  • Lv. 13 Rookie
  • Total EXP: 1028

Re: Azure and Orchard - which Cache Modules to use?

Amazing as per usual jtkech! Thanks a lot for the indepth synopsis. I did come across and subsequently edited the HostComponents.config with a performance improvement (I dont think I disabled FileParser, so I will also give that a shot) - will let you know how I get on, but that is of great assistance already :) So thanks again, Pug

Thursday, September 15, 2016 5:46:52 AM bypug
  • pug
  • Lv. 04 Rookie
  • Total EXP: 144

Post a reply

You need to be signed in to post a reply.

Sign In