SharePoint Pages intermittently load slowly

This post has been republished via RSS; it originally appeared at: SharePoint Support Blog articles.

Symptom


Have you ever experienced intermittent but short-lived delays while rendering your SharePoint site, which seems to correct itself, but then returns at random times?  If so, read on... as the issue detailed below may be occurring in your Farm and going unnoticed.

 

If you happen to catch one of the delays in action while verbose logging is enabled look for the following sequence of events.

 

First, you will see an event indicating that there was a change that caused web object to become invalid inside the cache.

 

Example:

 

w3wp.exe (0x2110)        0x07A8        Web Content Management        Publishing Cache        ck13        Verbose        
Processing change collection, found SPChangeFolder with SiteId: cc34283e-705b-42cc-8c2c-ef60c62fc104,
WebId: a0b84d6e-0ae4-40eb-8558-8bc5c7137a3d, FolderId: 35025da8-11d9-4bc9-8308-6b6d152ca4d0,
ChangeType: Add, queueing web for invalidation

 

As a result, a web level resync is triggered.

 

w3wp.exe (0x2110)        0x07A8        Web Content Management        Publishing Cache    ahh6z        Verbose       
InvalidateDependencesOnWeb
: Enqueuing web to resync for web id = '/' url = '/'.

 

Followed by many entries in the ULS log indicating that publishing pages are being cached.

Example:

 

w3wp.exe (0x1440)        0x0F50        SharePoint Foundation        Monitoring        nasq        Verbose        
Entering monitored scope (CachedObjectFactory: Caching Page at: /PAGES/HOME.ASPX).
Parent Microsoft.SharePoint.Navigation.REST.NavigationServiceRest.MenuState

 

These sequence of ULS events indicate a change caused the web object in cache to be invalidated and repopulated.

 

The change that triggered this issue is tracked inside the event cache table of the associated content database. Looking at events during this time, you may see an event type of 4096 and 4097, which indicates an "object add" and the URL associated will be "_catalogs\Users list".

 

Cause


This is by design and is easily reproducible while utilizing the SharePoint publishing features.

 

After adding a new user to Sharepoint site permissions, the new entry is only written to the "User Information List" after the user accesses the site for the first time.

 

So, in this case, when the user is attempting to render the page for the first time, an object cache invalidation and re-population will occur. This could occur minutes, hours or days after the user was added to the site permissions.

 

In large environments, with many publishing pages, the process of re-writing all pages into the Object Cache and take several seconds and sometimes measured in minutes for our "very large" farms.

 

Resolution


To avoid this issue during unexpected times, please consider the following solution.

 

1. Use EnsureUser API to when creating new users.  This will give you the ability to control when the cache becomes invalid and repopulated by forcing the ADD to the "User Information List" before the user logs on the for the first time.

 

Example:

 

$s = get-spsite "http://spfarm" 
$w = $s.rootweb
$w.EnsureUser("contoso\newuser7") 

 

2. Reduce the number of pages in the pages library to ensure that re-caching process is more efficient when invalidation occurs.

 

More Information


SPWeb.EnsureUser method

https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.spweb.ensureuser.aspx

 

Checks whether the specified logon name belongs to a valid user of the website, and if the logon name does not already exist, adds it to the website.

 

Cache settings operations in SharePoint Server 2013

https://technet.microsoft.com/en-us/library/cc261797.aspx

 

Object cache

 

The object cache reduces the amount of traffic between the web server and the SQL database by storing objects —such as lists and libraries, site settings, and page layouts —in memory on the front-end web server computer. As a result, the pages that require these items can be rendered quickly, increasing the speed with which pages are delivered to the client browser. Object cache settings can be configured at the web application level, and at the site collection level. By default, the object cache is on at the site collection level.

 

You can optimize the object cache for a web application by specifying the size of the object cache. Specifying a larger number can enhance performance for some large sites at the cost of memory on each front-end web server. You can configure other settings for the object cache at site collection level.

 

Note: To use the object cache, you must be using the Publishing feature on your site.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.