Archive
Monthly
Go
|
|
DNN Blog
Apr
24
Posted by:
Charles Nurse
4/24/2007
Last week I was asked to help troubleshoot some performance issues with a large site running on a Web Farm. In order to support Web Farms there are two settings in the web.config AppSettings.
- WebFarmEnabled
- CachePersistence
What do these settings do? Well, in short they are used to help the memory-based caches remain in sync with each other in a Load Balanced situation.
If both settings are set to false, then the Cache is saved in the memory of the server processing the request. If the Cache is cleared, for whatever reason, then the other servers are not "informed" of this so their Caches remain out of sync.
If the first setting "WebFarmEnabled" is set to true, then the Cache is still just saved in the memory of the server processing the request. However, a Cache Dependency is applied to the Cache which is dependent on a file which is persisted in the common Portal Home Directory. As each server's cache has a dependency on the same file, if the file is modified - then the cache is invalidated and the object will be reloaded from the database, and recached.
This file ONLY affects the cache IF it is changed - this the servers manage their own memory cache and the common file is used to invalidate - and keep in sync - memory caches if there is a change.
If the second setting "CachePersistence" is set to true then the same common file is created, except that the cached object is actually serialized to this file. This allows the cache to be persisted across Application Restarts. As long as the cache has not been explicitly cleared, then the cache provider can load (deserialize) this object back to the cache if the memory based cache has expired - which would be the case if the Application restarts.
So far so good. However, the real point I want to make in this Blog is that this second setting can even help in situations where a web farm is not being used. If you enable Cache Persistence and the memory cache expires then the Caching Provider first tries to load the object from the file saved in the common Portal Home Directory, and only if this has been explicitly cleared does it load from the database.
If you are in a situation where the database is a "Gating Resource" then you should consider using the setting.
Note: Not all cached objects are "persisted" in this way. In addition to the AppSetting, the code has to call a specific method of the DataCache class. Cached collections that are persisted in the core include:
- Portals
- Tabs
- Modules
- TabPermissions
- ModulePermissions
9 comment(s) so far...
Re: Cache Persistence - Just for Web Farms?
Hi Charles, Am I correct in my understanding that this does not apply if one has set the Module Caching Method is set to "Memory"... I'm assuming that an application restart will always wipe a ram-based cache and that the article is referring to disk-based 'memory' as the cache? Or have I got that wrong. Regards, Rob
By robax on
4/26/2007
|
Re: Cache Persistence - Just for Web Farms?
Rob - This is not related to the Module Caching setting - which caches the rendered output, but to the caching that caches the objects saving db hits.
By cnurse on
4/26/2007
|
Re: Cache Persistence - Just for Web Farms?
Ah got it thanks, that makes sense.
By robax on
4/26/2007
|
Re: Cache Persistence - Just for Web Farms?
EnableCachePersistence issue in DNN 4.5.1:
If (fresh genuine install, all other settings unchanged) is set in web.config (before install), then the order of the menu items in 'Admin' menu are wrong.
In addition, in this case, the GUID in 'Site Stettings' is 00000000-0000-0000-0000-000000000000.
I checked it twice, so I guess here's something wrong.
Added to the bug tracker today (DNNP-5581).
By deanman1 on
4/29/2007
|
Re: Cache Persistence - Just for Web Farms?
I think that is due to how it is serialised - and deserialized but thanks for the comment.
By cnurse on
4/29/2007
|
Re: Cache Persistence - Just for Web Farms?
Thanks for your kind words. Well, I gave it a third try (after re-installing DNN with EnableCachePersistence" value="false" before) and what can I say? No it's working again as expected! I guess that when using EnableCachePersistence" value="true" and re-installing DNN again with this setting, this behaviour comes up. However, I will check this issue again and let you know if this happens again. Perhaps, the server had a bad day... :)
By deanman1 on
4/29/2007
|
Re: Cache Persistence - Just for Web Farms?
Hi Charles, Can you explain what I could do for a WebGarden. I noticed when I set the "Max worker processes allowed" to 2 or higher in the application pool, you get a problem with caching..... Can I prevent this in any way?
By trouble2 on
7/19/2007
|
Re: Cache Persistence - Just for Web Farms?
Perhaps you could add this to the help section, or add it to the documentation somewhere
By trouble2 on
7/19/2007
|
Re: Cache Persistence - Just for Web Farms?
Charles... I'm using file based caching in a web farm (recommended set-up) situation... I get intermittent FileIO errors on the cache dependencies when browsing the site. I seem to get them consistiently when installing large modules (like Blog and some 3rd party mods like Catalook) Usually in the last pase of the install... I think it's the registering section.
All permissions are set properly, so that's not it. I've seen some people recommend moving to the databased cache scheme but I'm concerned that the DB hits would be or become an issue.
have you run across this?? Oh ver 4.8
By ldownes1221 on
2/5/2008
|
|