SharePoint warmup script for loadblanced WFE’s

There are many warmup scripts out there, but every time I checked and tested them, I found that there wasn’t any logic kept in mind for loadbalancers. Consider the following scenario: on WFE#2 I run my warmup script. It fires up and calls http://sharepoint. The lookup is done on the DNS server and there the loadbalancer’s IP is returned. After this process, it’s a random guess where my warmup script will hit.

sharepoint warmup script loadbalancing

WFE#1? WFE#2? I want both warmed up, so I took a nice and easy script and added a few lines of code to proxify the connection to the local server. By doing so, I’m sure that my script will hit the WFE where I do the warmup.

Add-PSSnapin Microsoft.SharePoint.Powershell

function Get-WebPage([string]$url)
    $bypassonlocal = $false
    $proxyuri = "http://" + $env:COMPUTERNAME
    $proxy = New-Object system.Net.WebProxy($proxyuri, $bypassonlocal)
    $wc = new-object net.webclient
    $wc.credentials = [System.Net.CredentialCache]::DefaultCredentials
    $wc.proxy = $proxy
    $pageContents = $wc.DownloadString($url)
    return $pageContents

Get-SPAlternateUrl -Zone Default | foreach-object {
    write-host $_.IncomingUrl
    $html = Get-WebPage -url $_.IncomingUrl

A final note: I found that proxifying the connection to the local server does not work when the Loopback check is enabled. More on this here. Another workaround would be to specify WFE#1 as a proxy on WFE#2 and vice versa.

So on WFE#2:

$ProxyUri = "http://WFE#1"

And on WFE#1

$ProxyUri = "http://WFE#2"

One thought on “SharePoint warmup script for loadblanced WFE’s

  1. Pingback: SP Warm-up « RaSor's Tech Blog

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s