« Previous Next »

Thread: Preload web application after WP recycle

Last post 09-25-2009 8:26 PM by lextm. 19 replies.

Average Rating Rate It (5)

RSS

Page 1 of 2 (20 items) 1 2 Next >

Sort Posts:

  • 09-21-2009, 4:01 AM

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Preload web application after WP recycle

    Hello,

    I have a third party web application (well suite of them) that we have bought and host on two of our web servers (IIS6 & IIS7). The web application is .NET based but uses a lot of Java on the pages. My users are complaining about the length of time it takes to logon in the morning to this site and so I thought I would disable the 'Shutdown worker process if idle' setting and force the application pool to recycle each night. My aim was then to call the logon page via an automated script shortly after the recycle to preload the web application into the cache. Unfortunately for me this doesn't seem to be working quite as intended and the users still get the long wait for the logon page, but once the first user is in then subsequent requests are a lot quicker.

    Here's the script i was trying to use:

    :: Prevent any spaces in the batch from being read
    @echo off

    :: Start Internet Explorer and request it displays the main InfoView page
    start http://myserver/InfoViewApp/listing/main.aspx

    :: Delay this script for a length of three minutes to allow page to load
    :: -n 181 = 181 pings, now + 180, each lasting 1 second (i.e. 3 minutes)
    :: -w 1000 = timeout of 1000 milliseconds to wait for each reply
    :: > nul = a redirection to nul which effectivly suppresses the ping reports
    ping 127.0.0.1 -n 181 -w 1000 > nul

    :: Forcefully close down any Internet Explorer processes that are running
    taskkill /F /im iexplore.exe

    I get the impression that this line of reasoning is not invalid, but I haven't yet found a suitable way of implementing it.

    If anyone can confirm or debunk my idea that would be great.
    Likewise, if anyone can point me in the right direction to preload my site that would also be great.

    Thanks,

    Mike

  • 09-21-2009, 4:59 AM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 4:18 AM
    • Shanghai, PRC
    • Posts 1,406

    Re: Preload web application after WP recycle

    The best way I can think of for IIS 6 is to write a PowerShell script to ping the page. PowerShell has many ways to implement "wait for a few seconds". But you can also write your home cook application with .NET/VC and so on. For a console application, it does not take much more time than writing a script.

    But if you really expect the "preload" feature, take a look at Scott's latest blog post here,

    http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-21-2009, 5:27 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    Lex,

    A good link to Scott's page, but unfotunately I am not yet using IIS7.5 and so can't yet take advantage of his solution. It's nice to see that it will be there in the future when we eventually get around to upgrading.

    Can you think of any reason why my script didn't do what I had hoped it would?

    Can you suggest any links to script pages demonstrating how to complete my task? I've tried looking, but I guess i've just got the wrong search terms stuck in my head as I don't seem to be able to find anything usefull.

    Mike

  • 09-21-2009, 5:59 AM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 4:18 AM
    • Shanghai, PRC
    • Posts 1,406

    Re: Preload web application after WP recycle

    I am not sure why your script failed. But if you don't plan to write your own console application or PowerShell script, you can download and install Windows Server 2003 Resources Kit Tools from here,

    http://www.microsoft.com/Downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

    After installing you can find a tool named sleep.exe under %ProgramFiles%\Windows Resource Kits\Tools

    Using this tool in your script so that you can control how many seconds to wait for.

    C:\Program Files\Windows Resource Kits\Tools>sleep
    Usage:  sleep      time-to-sleep-in-seconds
            sleep [-m] time-to-sleep-in-milliseconds
            sleep [-c] commited-memory ratio (1%-100%)

    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-21-2009, 6:19 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    Thanks again for responding. I guess I mis-phrased my question as I had intended to ask 'do you think that my script should do what I intend it to do (i.e. preload the app)?'.

    Thanks,

    Mike

  • 09-21-2009, 11:14 PM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 4:18 AM
    • Shanghai, PRC
    • Posts 1,406

    Re: Preload web application after WP recycle

    I think so. Pinging a page periodically can prevent IIS from shutting down the worker process for that application pool.

    However, make sure you don't set another web browser as default web browser on that computer. :) Otherwise, this script cannot shut it down.

    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-23-2009, 3:04 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    The script is not a 'keep alive' script in the traditional sense as I have disabled the 'Shutdown worker process when idle for' setting and forcibly refresh the app pool every night. The script was intended to to prepopulate the cache after the refresh, but it doesn't seem to be doing that as the users still have a long wait fot the first request (compile time I assume). 

    I've checked and IE is  definitly the default browser on the server.

    The only reason I can think of the script not working is because the owner of the iexplore.exe process is the SQL service account and not a standard domain or local computer account. I don't know if this has an effect on the actual operation of the request for a page that I included in my script. I can't see why it would, but i'm clutching at straws trying to figure out why the cache is apparently empty after the script is run. I'm fairly convinced that the script was doing the job when I ran the command file on the server, i.e. ran it from the same account I was logged in as.

    Do you know of any way I can test the cache to see what it contains, or at least if it contains anything?

    Mike

  • 09-23-2009, 6:29 AM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 4:18 AM
    • Shanghai, PRC
    • Posts 1,406

    Re: Preload web application after WP recycle

    If the very first response is still slow when the script is running, I think the problem you face is really application specific and has little to do with IIS/ASP.NET infrastructure which has already been warmed up by this script.

    Then please do a deeper analysis of the web application itself and identify why it is slow for the very first time. What initialization does the application perform to speed up later responses? If we don't know that thing for sure, we couldn't find a way to resolve it.

    I don't understand what "cache" you mentioned, so I don't have an idea how to track it down. If that's managed by your ASP.NET code, consider printing out some application log to track down its activities. Maybe that can provide more information.

    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-23-2009, 7:16 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    Ah, unfortunately it's a third party application and they are being a little unhelpful in this matter, hence my attempt at finding an alternate solution. Their inital attempts have been to suggest that I disable the 'Shutdown worker process when idle for' setting and disable the recycle options so that it remains in memory forever. This doesn't sound like a good idea to me, hence my attempt to call the site after I forceibly recycle the app pool out of hours.

    I thought (and i've probably got this wrong) that when a first request is made of a .NET web application that the JIT compiler kicks in and compiles the code but that then the site was loaded into the servers memory. It was this second stage that I thought was the population of the cache, but now you've got me wondering if i've misunderstood the process. Can you confirm if my understanding is correct or not?

  • 09-24-2009, 2:56 AM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 4:18 AM
    • Shanghai, PRC
    • Posts 1,406

    Re: Preload web application after WP recycle

    Your understanding about ASP.NET web site start up/warm up is almost right. But like I said, if you made use of the script, then the warm up process is executed before later requests and it will not be the bottleneck anymore. So if slowness remains, it must come from another part of the system.
    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-24-2009, 3:21 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    I guess it must be doing something else after the first load then :-(

    Unfortunately the symptoms only exist for the first user to logon and not for subsequent users even after my script has run. I guess i'll have to go back to the vendor (BusinessObjects) to see if they can have another go at comming up with a solution.

    You say that my understanding is almost right. Can you advise me where it is not right?

    Thanks for discussing the matter.

    Mike

  • 09-24-2009, 3:23 AM In reply to

    • Moshe L
    • Not Ranked
    • Joined on 01-18-2009, 2:55 PM
    • Posts 2

    Re: Preload web application after WP recycle

    Why not use wget (free - GPLed) or something similar ?
    IE is very expensive and  "taskkill" is not the optimal way to do this.
  • 09-24-2009, 4:26 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    I did look at wget and it was my first attempt at the script, but it seemed like additional overhead to install/maintain a new bit of software when (theroetically) the Start command would do the same job. I totally agreee with you though that Taskkill is far from an optimal solution.

    Are you able to describe the differences between wget and the Start command? Do they both have the same effect on the server in that the site is made to compile and hence improve the first user request? The two problems I had with wget were configuring it to not actually create a file of the obtained page and it seemed to require authentication credentials to be stored in the command line. I tried using the --spider command to solve the first problem but that failed authentication. I also tried a command to delete the file but this seemed sub-optimal. I considered using configuration files for the second problem but that seemed like too much maintenance and documentation when compared to the Start command.

    Mike

  • 09-24-2009, 5:22 AM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 4:18 AM
    • Shanghai, PRC
    • Posts 1,406

    Re: Preload web application after WP recycle

    Start is a shell command that launches IE to link to the URL. This is an expensive action as all you need in fact is sending out an HTTP request. Maybe wget is a lighter solution. TinyGet bundled in IIS 6 Resource Kit is another thing you can evaluate. http://www.microsoft.com/downloads/details.aspx?FamilyID=56FC92EE-A71A-4C73-B628-ADE629C89499&displaylang=en
    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-24-2009, 10:19 AM In reply to

    • renMike
    • Top 500 Contributor
    • Joined on 09-30-2008, 3:13 PM
    • Posts 21

    Re: Preload web application after WP recycle

    I run into one of the same problems with TinyGet as I did with WGet and that is I have to supply a user name and password. Since this is intended to run as a scheduled task on a server the chances are that no user will be logged in so I can't use the -u:CurrentUser switch. It does have the benefit of not actually retrieving the page to file.

    Surley this must be a fairly common problem that people want to request pages from a site to 'keep it alive'/'warm it up' but don't want to expose user credentials in plain text files. The only way I can think of doing this now is to write a console app to do the work and that can retrieve username and details from a secure password repository. Seems like overkill for what should be a simple task. Am I trying to use these tools incorrectly?

    Mike

Page 1 of 2 (20 items) 1 2 Next >
Microsoft Communities