The Problem:
Whenever the App Pool is re-cycled or a user adds, renames or deletes a site the application becomes unresponsive for 5-7 minutes. During this time users who try to access the site receive timeouts.
Analysis:
The menus are using the SharePoint PortalSiteMapProvider control to retrieve the Site and Page structure of a large branch of a site hierarchy.
PortalSiteMapProvider enumerates all Sites and Pages (there are 2066 sites in that structure but few individual pages) and caches these in memory, along with user authorisation information for all these (there are 25,000 users - but Domain Groups used mainly).
The menus display this cached information.
Whenever anything changes on the site, this cache is invalidated and all the information must be re-queried - this takes 5-7 minutes during which time the site is unusable.
Solution:
None so far. We tried limiting the number of levels that the ASPMenu control asks for to 2 (by setting the specific branch Menu's MaximumDynamicDisplayLevels property to 2. This reduced the time taken to rebuild the menu to 1.5 minutes which stopped the problem form occurring but this is not acceptable (means we cannot see all the sites and pages we need).