How to improve startup performance on IIS / ASP.Net

前端 未结 5 1221
灰色年华
灰色年华 2021-01-05 08:20

I am using a particularly slow virtual web host (name withheld!) where disk performance can be very bad. Thus, the first hit to my ASP.Net web sites can take 1+ minutes to l

相关标签:
5条回答
  • 2021-01-05 08:31

    How much of the site do you want to have pre-loaded? How many pages?

    You can pre-compile the site, to remove the "compilation" part of the issue, but if the site is large enough, it may not make sense to "pre-load" the site. This would be especially true if the site runs on multiple hosts.

    0 讨论(0)
  • 2021-01-05 08:37

    If your provider can have a way for you to hook into when they are restarting the web server, you can have a batch file / script file hitting your website after the the web server restart. You'll only need to hit unique ASP.NET assembly files to get that particular assembly into memory. So if you have 1 assembly containing 10 pages, just hit one of the pages. It should be enough. If you have more than 1 assembly, hit 1 page in each assembly to load those assemblies into memory.

    If you can't have it at your provider, then you have to think of a smarter way to do this on your own (i.e. learn when the provider is resetting the web server and schedule task in your machine to hit those pages yourself).

    0 讨论(0)
  • 2021-01-05 08:39

    The first time you request a page from a compiled ASP.NET application after its assemblies have been modified, it takes a lot longer to process than a normal page request.

    A simple solution to your problem is therefore to request a page from your application immediately after any modifications. That way you are the first to request a page, and you incur the long wait rather than your users.

    0 讨论(0)
  • 2021-01-05 08:45

    Does your application need to recycle? All of the recycle options are in the IIS configuration and can be adjusted to be appropriate for your application.

    The ideal scenario would be to remove all of the application recycles so that the application always remains loaded. Recycling would then only occur if the web.config file was changed or a new version of the application was deployed.

    If daily recycling is required, as per the previous answer, a batch file could be used to recycle the application and it could also call iexplore.exe with the URL of the application to "pre-load" it.

    0 讨论(0)
  • 2021-01-05 08:48

    why can't you have a batch file that has iis reset in it and have it schedule to execute every day at a certain time (when you have no users on your system)?

    0 讨论(0)
提交回复
热议问题