Small spike in load times every minute

The problem

This week I was asked to help out one of our customers. They were looking into a performance issue of their SharePoint 2013 on-premise farm. Occasionally they experienced a spike in load times (which can be caused by a search index, backup operation etc.).

To get an indication how often the spike in load times occurred, they used a PowerShell script which loads the home page of their Intranet every 10 seconds and logs the load time. The results showed that the load time of the page was less than 100 milliseconds 5 times in a row and then it increased to 700 milliseconds. Even though this wasn’t the issue they were looking for (the spikes they were investigating were 7-10 seconds), this was something they couldn’t figure out. The 700 milliseconds load time itself isn’t really an issue, but not knowing what causes these spikes is.

The answer

Using the ULS log, we traced the 700 millisecond requests and found the actions which were taken at that time and compared those actions to the actions taken when the page loaded in less than 100 milliseconds. The additional actions comprised of 7 cross site queries which were performed. These queries were performed for loading the Content By Query WebParts on the home page. Just to check how much time those queries cost at the database layer, we traced the queries using the SQL Server Profiler. All these queries were pretty quickly and they only accessed information of a specific list.

The reason the Content By Query WebParts only load once a minute, is because the home page is a publishing site. By default publishing sites cache the pages for a minute. So most hit within that minute can be retrieved from cache, but once a minute the latest data is requested by the queries and parsed. This only shows that the cache mechanism of SharePoint really helps out with increasing your performance.

 

Advertisements
Categories: SharePoint

Creating new document via SharePoint 2013 shows Page not Found

Today I was working with SharePoint 2013 and I wanted to create a new Word document in a document library. When I clicked on the New Document button, I got a The webpage cannot be displayed error. The URL of the page was: ms-word:nft|u|http://[customerurl]/Documents/Forms/template.dotx|s|http://[customerurl]/Documents

The problem I had was that my client PC had Office 2010 AND SharePoint Designer 2013. When you have applications of Office 2013 next to Office 2013 on your machine, you might get this issue. This means both Office versions have Microsoft SharePoint Foundation Support installed. You can either remove this from one of the versions, or just install SP2 for Office 2010.

Categories: Environment, SharePoint

Display templates not reflecting ALL changes

April 10, 2014 4 comments

Lately I’ve been working a lot with custom display templates and custom refiners. This worked all pretty well, I could update the look and feel by changing the body without any problem. However, when I made changes in the head section of the display template, this didn’t seem to reflect my changes… And there you update your Managed Properties and in my case I also added some logic to retrieve some variables.

Using the debugger of Internet Explorer I saw the old version of the Javascript files were still used for the display templates. Somehow these where cached… The URL of my display template ended with ?ctag=122$$15.0.4481.1005. Well this number of course can change, but somewhere the old version was still in the SharePoint cache. This led me to look at my Result Types, since my display templates are used based on those…

On the top of the page I found the following message:

PropertySyncNeeded

Just click the Update link and you will get the following message:

PropertySyncDone

Refresh your search result page and the latest version of your display template will be used!

Generate overview of active features

For now the last section about generating documentation for your custom SharePoint solution. The following PowerShell scripts will provide you with an overview of activated features on your Farm, WebApplication and Site Collections. Since this script is meant for custom solutions, I assume you have used a prefix (Visual Studio adds the solution name by default as a prefix to all features).

Activated farm features

#———————————————————————————————————————-
# Add SharePoint PowerShell Snapin 
#———————————————————————————————————————-
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
    Add-PSSnapin Microsoft.SharePoint.Powershell


#———————————————————————————————————————-

# Get variables
#———————————————————————————————————————-
$featurePrefix = “Macaw”

#———————————————————————————————————————-
# Get information
#———————————————————————————————————————-
Get-SPFeature | where {$_.Scope -eq “Farm” -and $_.DisplayName.StartsWith($featurePrefix ,“CurrentCultureIgnoreCase”)} | Select DisplayName

Activated web application features

#———————————————————————————————————————-
# Add SharePoint PowerShell Snapin 
#———————————————————————————————————————-
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
    Add-PSSnapin Microsoft.SharePoint.Powershell

#———————————————————————————————————————-
# Get variables
#———————————————————————————————————————-
$featurePrefix = “Macaw”

#———————————————————————————————————————-
# Get information
#———————————————————————————————————————-
Get-SPWebApplication | foreach {
    Write-Host ([string]::Format(“Web Application: {0} ({1})”, $_.DisplayName, $_.Url))
   $_.Features | where {$_.Definition.DisplayName.StartsWith($featurePrefix ,“CurrentCultureIgnoreCase”)} | foreach {
        Write-Host ([string]::Format(“- {0} ({1})”, $_.Definition.DisplayName, $_.Definition.Id))
    }

    Write-Host “”
}

Activated site collection features

This script skips all personal sites, which you can easily add to your overview by removing the where clause.

#———————————————————————————————————————-
# Add SharePoint PowerShell Snapin 
#———————————————————————————————————————-
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
    Add-PSSnapin Microsoft.SharePoint.Powershell

#———————————————————————————————————————-
# Get variables
#———————————————————————————————————————-
$featurePrefix = “Macaw”

#———————————————————————————————————————-
# Get information
#———————————————————————————————————————-
Get-SPWebApplication | Get-SPSite | Where { $_.Url -notmatch “/personal/”} | foreach {
    Write-Host ([string]::Format(“Site Collection: {0} ({1})”, $_.RootWeb.Title, $_.Url))
   $_.Features | where {$_.Definition.DisplayName.StartsWith($featurePrefix ,“CurrentCultureIgnoreCase”)} | foreach {
        Write-Host ([string]::Format(“- {0} ({1})”, $_.Definition.DisplayName, $_.Definition.Id))
    }

    Write-Host “”
}

Previous posts about automatically generate documentation of your custom solution:

Generate solution documentation

April 3, 2014 1 comment

Sometimes you want an overview of your custom farm solutions which are deployed on your farm. Normally I prefix all my solutions to make it clear who created them. Using this prefix you can easily run a PowerShell script which provides you with a list of installed solutions and the web applications to which these solutions are deployed:

#———————————————————————————————————————-
# Add SharePoint PowerShell Snapin 
#———————————————————————————————————————-
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
    Add-PSSnapin Microsoft.SharePoint.Powershell

#———————————————————————————————————————-
# Get variables
#———————————————————————————————————————-
$solutionPrefix = “Macaw”

#———————————————————————————————————————-
# Get information
#———————————————————————————————————————-
foreach($solution in Get-SPSolution | Where {$_.Name.StartsWith($solutionPrefix ,“CurrentCultureIgnoreCase”)}) {
    Write-Host “Name: “ $solution.Name
    Write-Host “Identity: “ $solution.Id

    if($solution.get_ContainsWebApplicationResource() -eq $false) {
        Write-Host “Applications: Globally deployed”
    }
    else {
        Write-Host “Deployed to application(s):”
        $solution.DeployedWebApplications | foreach-object {
            Write-Host ([string]::Format(“- {0} ({1})”, $_.DisplayName, $_.Url))
        }
    }

    Write-Host “”
}

For a PowerShell script which documents all features, look at this post.

Replace SharePoint special characters

Sometimes during SharePoint development item are programmatically added to SharePoint based on for example the title of the site, which can contain special characters. This can occur when creating documents, SharePoint groups etc. You will receive a message stating that the following characters are not allowed: / \ [ ] : | < > + = ; , ? * ‘ @

In my case I wanted to create custom SharePoint groups based on the title of the web. To avoid these errors when characters like that are used in the Web title, I’ve used a regular expression to remove these characters. This can be accomplished by the following lines of code:

// Ensure SharePoint safe title (characters [“/\[]:|<>+=;,?*’@] are not allowed)
Regex pattern = new Regex(“[:\\[\\]|<>+=;,\\?\\*’@\\\”\\\\/]?”);
string title = pattern.Replace(web.Title,“”);

Categories: Development, SharePoint

Generate feature documentation

March 31, 2014 2 comments

For my projects I always provide documentation about the solutions our team has developed. Part of the development is an overview of the features which are added to the different solutions. This because most of the features tend to be hidden and the customer and administrators will not use Visual Studio to check which features are added.

As most developers I don’t like to document everything twice and on multiple locations. All features in my project are already documented in Visual Studio. I’ve added titles, images, descriptions etc. This information can easily be reused to generate documentation about the features. For that, I use the following PowerShell script:

 

# Set the feature folder based on the SharePoint version
$featureFolder = “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES”

# Provide a prefix to filter the set of features
$featureFolderPrefix = “Macaw.”

# Initialise a counter
$counter = 0

# Loop through all features
foreach($folder in Get-ChildItem -LiteralPath $featureFolder | where { $_.PSIsContainer -and $_.Name.StartsWith($featureFolderPrefix,“CurrentCultureIgnoreCase”) }) {

   #Increment the counter
   $counter++

   # Retrieve the feature XML
   $featureXML = Get-ChildItem $folder.FullName -Filter feature.xml -Recurse
   [xml] $featureContent = Get-Content $featureXML.FullName
   $feature = $featureContent.Feature

   # Write some of the properties to screen
   $feature | select Title, Description, Id, Scope,
     @{Label=“Hidden”;Expression={if($featureContent.Feature.Hidden) { “Yes”} else { “No”}}},
     @{Label=“Full name”;Expression={$featureXML.FullName}},
     
@{Label=“Number”;Expression={$counter}}

   # Split the results with an empty row
   Write-Host “”
}

Ben Prins

What I want to remember about SharePoint

blog.frederique.harmsze.nl

my world of work and user experiences

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure