Udostępnij za pośrednictwem


SharePoint 2013 Environment Latency and Network Test Script

The intra-farm latency requirement of SharePoint is one of the hardware requirement, described at https://technet.microsoft.com/en-us/library/cc262485.aspx 

It can be difficult to test and is often left un-verified because short of having a server sit there and ping the rest of the farm for 10 minutes, there is no way to ensure that the environment is compliant.  To solve this, I have written a script that leaves one of the servers sitting around pinging the rest of the farm for 10 minutes and reports back on whether the environment complies.

The Script performs the following tests:

 - Check connectivity in the farm and make sure all servers are reachable. (this saves you from wasting 10 minutes waiting for the script to run only to find out the hosts weren't reachable)

 - Open an ODBC connection to the database server. (This is always handy)

 - Verify the environment meets the SharePoint hardware requirement that 99.9% of pings between servers in the farm take less than 1ms over a 10 minute period.  For convenience, how long this runs can be changed by setting the $RunTime variable to a lower value.

 

To run the script, either copy and paste the code into PowerShell_ISE and run it, or save it as a .ps1 file, right click it and select "Run with PowerShell".  The second method requires the powershell execution policy to be "unrestricted" (to set, run Set-ExecutionPolicy Unrestricted).

  #####Set Local Variables
 #Set Host Names, or IP Addresses
 $hostnames = "10.0.0.1", "SomeHost"
 #SQL Server Name\Instance
 $SQLname = "SQL\Instance"
 #Configure Run Time in Minutes (helpful for debugging)
 $RunTime = 10
 #Configure an allowance for late pings (in ms, one way)
 $allowance = 0
 #####
 
 ### test connectivity ###
 Write-Host "Test Connectivity:"
 
 Write-Host "Testing Ping"
 $ping = New-Object System.Net.NetworkInformation.ping
 
 foreach($a in $hostnames){
 $status = $ping.send($a).Status
 if($status -ne "Success"){
 throw "Ping Failed to $($a)"
 }
 }
 Write-Host " - Succeeded `n"
 
 
 
 ### test SQL connectivity ###
 Write-Host "Testing SQL Connection"
 $SQLConnection = New-Object System.Data.Odbc.OdbcConnection
 $SQLConnection.connectionstring = "Driver={SQL Server};Server=$SQLname"
 $SQLConnection.open()
 if($SQLConnection.state -ne "Open"){
 throw "SQL Connection Failed"
 }
 Write-Host " - Succeeded `n"
 
 
 
 ### Intra-server latency consistency test ###
 Write-Host "Start network consistency test"
 
 
 $ScriptBlock = {
 # accept the loop variable across the job-context barrier
 param($InHost, $RunTime) 
 
 $start = [DateTime]::Now
 $ping = New-Object System.Net.NetworkInformation.ping
 
 $PingResults = @()
 while([datetime]::now -le $start.AddMinutes($RunTime)){ 
 $outping = $ping.send($InHost)
 if($outping.Status -ne "Success"){
 $PingResults = $PingResults + 100
 } else{
 $PingResults = $PingResults + $outping.RoundtripTime
 }
 Start-Sleep .1
 } 
 return $PingResults
 }
 
 
 #run ping jobs in parallel
 foreach($i in $hostnames){
 Start-Job $ScriptBlock -ArgumentList $i, $RunTime -Name "$i.latency_test"
 }
 
 Write-Host "
 processing...`n"
 
 #wait and clean up
 While (Get-Job -State "Running") { Start-Sleep 5 }
 
 $output = @{}
 foreach($i in $hostnames){
 $output[$i] = Receive-Job -Name "$i.latency_test"
 }
 Remove-Job *
 
 #test results
 $LatencyTestFailed = 0
 foreach($i in $hostnames){
 $BadPings = $output[$i] | ?{$_/2 -ge 1 + $allowance}
 $PercentBadPings = $BadPings.length / $output[$i].Length * 100
 if($PercentBadPings -ge .1){
 "$i DOES NOT meet the latency requirements with $PercentBadPings % of pings >$(1+$allowance)ms" | Write-Host
 $LatencyTestFailed = 1
 } else{
 "$i meets the latency requirements with $PercentBadPings % of pings >$(1+$allowance)ms" | Write-Host
 }
 }
 if($LatencyTestFailed -eq 1){
 throw "Farm Latency Test Failed"
 } 

Comments

  • Anonymous
    December 12, 2013
    Hi, Assume this script can be run for SP2010 farms as well? /A

  • Anonymous
    January 07, 2014
    Should be compatible, it does not make use of any SharePoint features.

  • Anonymous
    March 07, 2014
    Hello,

    This is nice unless the icmp is disabled and you can't use the ping. This happen very often in real world scenario.

  • Anonymous
    May 20, 2014
    EricA has issued an improved version of this script which can be found here:
    http://blogs.msdn.com/b/erica/archive/2013/11/11/sharepoint-2013-network-latency-test-script.aspx

  • Anonymous
    June 23, 2014
    Hi Isabelle,
    ICMP is a requirement for the distributed cache and should be enabled in all production deployments. For more information please see Steve Peschka's blog:
    http://blogs.technet.com/b/speschka/archive/2013/01/11/configuring-multiple-distributed-cache-servers-in-sharepoint-2013.aspx
    -Alex

  • Anonymous
    June 24, 2014
    Hi Alex - Thanks for the script. It is very helpful! I'm kind of stuck right now and wanted to see if anyone had any thoughts how I should move forward.

    I set the SPServerNames to the 8 servers in our farm. When I run the script, 1-10% of the pings are greater than 1ms. This is obviously not good.

    So I tried a couple variations of the script:
    - If I change SPServerNames array to only include 1 server, 0-1% of the pings are greater than 1ms. Better but still not good enough all the time.
    - If I change the sleep time between pings to 1 second in the $ScriptBlock, 0-1% are greater than 1ms. I leave all 8 servers in. Again, Better but still not good enough all the time.
    - If I both change the sleep time and reduce the number of servers in the array, I can get 0% greater than 1ms.

    The MSDN technet article doesn't define criteria around number of simultaneous tests or the polling interval between pings. Any guidance or experiences or suggestions or thoughts? Thanks!

  • Anonymous
    June 24, 2014
    Good one

  • Anonymous
    June 24, 2014
    Need to try this.

  • Anonymous
    June 26, 2014
    Eric,
    That is an interesting finding, I will investigate. As long as your servers individually meet the requirements, even with the longer ping interval you should be alright.

  • Anonymous
    May 21, 2015
    The comment has been removed