SharePoint app pools recycle every night. Because they recycle every night the first person to hit SharePoint each morning has to wait for the app pools to warm back up.
To workaround this “bad behavior”, the startup scripts have been written to address this, and they all work fine.
This the script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$hname=hostname
function sendMail{
Write-Host “Sending Email”
#SMTP server name
$smtpServer = “smtp.xxxxx.xxx”#Creating a Mail object
$msg = new-object Net.Mail.MailMessage#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)#Email structure
$msg.From = from@xxxxx.xxx
$msg.ReplyTo = replyto@xxxxxx.xxx
$msg.To.Add(emailto@xxxxx.xxx)
$msg.subject = “Warm Up Script – SharePoint 2013″
$msg.body = “Warm Up Script has run on the server $hname.”#Sending email
$smtp.Send($msg)
}
Get-SPWebApplication | ForEach-Object { Invoke-WebRequest $_.url -UseDefaultCredentials -UseBasicParsing }#Calling function
sendMail
The –UseDefaultCredentials parameter tells Invoke-WebRequest to log in to the web site as the person that PowerShell is running as. –UseBasicParsing tells Invoke-WebRequest to use basic parsing of the web page. We really don’t care about the web page, we just want to wake SharePoint up to send it to us.
If you have multiple WFEs you’ll need to run this on each server.
A good tip here, is to try to find the event ids responsible to the recycle and set up an “eventtrigger” to start the warm up script automatically after this process.
In my scenario I have configured to run the warm up script automatically when the “5076”, “5078”, “5079” and “5080” events ids have occurred on my server.
You’ll probably need to modify this for your environment, but hopefully it will get you started.
No comments:
Post a Comment