So, the curse of the .NET web applications (and then some blessing) is the JIT that impacts the performance for the first -unfortunate- user to access the application first time in the morning, or just after an inconsiderate administrator/developer installed something on the server... so when your client is complaining about that response time, and you can't do anything to justify it but search for a solution, then comes the Warm Up script have seen in the Microsoft Virtual Labs.
Let's first understand what happens:
Why is it so #$%& slow?
Every web application in IIS need and Application Pool to run. The Application Pool recycle itself at one given time everyday and that's when all the compiled code in the cache goes to hell. But this recycling is needed, or else the process will eat your server memory to death... and that's not an option in a real production server!
So, after the Application Pool is recycled, when any user access the web application, by making an HTTP request (that mean, by typing the URL of the Web Application in their browser), the application begins the compilation process. Some of this is cached, so when a second user access the web application is faster for him.
Another proccess that causes the Application Pool to be recycled is when you stop and restart the Internet Information Services, as a whole or any given web application. And this task is very common when you're implementing new features on SharePoint or even creating new Web Sites.
A Solution
Even if it just happens for the first user everyday, that's not acceptable for most customers of the SharePoint projects i've work on.
There's a popular solution that you may have seen working if you've done a Microsoft Virtual Lab on SharePoint, and it's a little 'Warm Up' script that runs every time you start the Virtual Lab, and it's also recommended on many websites when you're working on Virtual Machines for client demostrations.
This script was posted by Joel Oleson on his SharePoint blog (http://blogs.msdn.com/joelo/archive/2006/08/13/697044.aspx) and it's been reported to be used in many SharePoint implementations... for those that haven't been able to use it, or use it and see no change in the performance at all, here's the detailed instructions:
- Download the 3 files for the script on Joel Oleson's blog post: WarmUpServer.zip
- Extract the files on your server/virtual machine/test computer/wherever sharepoint is installed in and you want the performance to be better for that first unfortunate user.
- Right click on the startup.bat file, and choose Edit (or just open it o notepad to modify it)
- In the "call WarmUpServer" line, modify the last parameter to the name of your SharePoint server, like this:
| call WarmUpServer servermoss1 |
- Copy that line and paste it for every server and web application you have in your farm. Like this:
call WarmUpServer servermoss1 call WarmUpServer servermoss2 call WarmUpServer servermoss1:3333 call WarmUpServer servermoss1:2222 call WarmUpServer servermoss2:4444 |
- Then, right click on the WarmUpServer.cmd file, and choose Edit (or just open it on notepad to modify it)
- Modify the "call :HitPage" line with the name of your server, or just replace it with %1 to use the parameter we already modified on the startup.bat, like this:
|
call :HitPage %1 /Pages/default.aspx call :HitPage servermoss1 /default.aspx |
- Add more lines with the url of the administrative pages or other sites you want to be specifically hit by the script, like this:
|
call :HitPage %1 _layouts/settings.aspx call :HitPage %1 _layouts/create.aspx call :HitPage %1 _layouts/newsbweb.aspx call :HitPage %1 _layouts/viewlsts.aspx |
- Create an scheduled task to run this script every day, after the time you know the Application Pools are recycled.
- Test it works:
- Open the command line (Start > Run... > type cdm)
- Reset the Internet Information Services (type iisreset)
- Find the startup.bat you just modified and double click on it.
- When the command line window that the startup.bat opened closes, Open Internet Explorer and type the URL of any of the SharePoint site you added to the script in step 5.
- If it opens the website fast (or whatever the usual expected speed is), Congrats! it worked.
- If it's still slooow then try this:
- Right click on the WarmUpServer.cmd file, and choose Edit (or just open it on notepad to modify it)
- modify the "cscript HttpRequest.vbs GET" line, and include the authentication, like this:
| cscript HttpRequest.vbs GET http://user:password@%1%2 /q //nologo |
Where user and password are the credentials for a valid user in SharePoint that has reading rights to the sites you add in step 5.
- Save the file and Go to step 10... that means, Test it!!
I bet it will work for you now!!! It's important that the user credentials you burn in the script in step 12, only has read rights (for obvious security reasons) and has no permissions on the server, or anywhere on your domain!! it's just for the script to correctly access the site not staying stuck in the authentication step before loading the site.
I'll add screenshot of the process, but right now i'm kinda tired, so see you later!