ASP.NET application on IIS7 - very slow startup after iisreset

后端 未结 7 1867
长发绾君心
长发绾君心 2021-02-05 16:41

I have an ASP.NET 3.5 website running under IIS7 on Windows 2008.

When I restart IIS (iisreset), then hit a page, the initial startup is really slow.

I see the f

相关标签:
7条回答
  • 2021-02-05 17:12

    We had a similar problem and it turned out to be Windows timing out checking for the revocation of signing certificates. Check to see if your server is trying to call out somewhere (e.g. crl.microsoft.com). Perhaps you have a proxy setting incorrect? Or a firewall in the way? We ultimately determined we had enough control over the server and did not want to 'call home', so we simply disabled the check. You can do this with .NET 2.0 SP1 and later by adding the following to the machine.config.

    <runtime> <generatePublisherEvidence enabled="false"/> </runtime>
    

    I am not sure if you can just put this in your app.config/web.config.

    0 讨论(0)
  • 2021-02-05 17:15

    Greater than 60 seconds sounds fishy. Try running a test.html page to see how long that takes. That will isolate IIS7's role.

    Then temporarily rename your web.config, global.asax and application folders and try a test.aspx page (very simple page). That will isolate ASP.NET.

    If both of those are fast (i.e. about 10 seconds), then it's your application. But, if either are slow then not the application and something with the server itself.

    0 讨论(0)
  • 2021-02-05 17:18

    I found that there was a network delay making an initial connection from the front end web server to the database server.

    The issue was peculiar to Windows 2008 and our specific network hardware.

    The resolution was to disable the following on the web servers:

    • Chimney offload state

    • Receive window auto-tuning level

    0 讨论(0)
  • 2021-02-05 17:20

    Thats the compilation of asp.Net pages into intermediate language + JIT compilation - it only happens the first time the page is loaded. (See http://msdn.microsoft.com/en-us/library/ms366723.aspx)

    If it really bothers you then you can stop it from happening by pre-compiling your site.

    EDIT: Just re-read the question - 60 seconds is very long, and you would expect to see some processor activity during that time. Check the EventLog for errors / messages in the System and Application destinations. Also try creating a crash dump of the w3wp process during this 60 seconds - there is an chance you might recognise what its doing by looking at some of the call stacks.

    If it takes exactly 60 seconds each time then its likely that its waiting for something to time out - 60 seconds is a nice round number. Make sure that it has proper connections to the domain controllers etc...

    (If there are some IIS diagnostic tools that would do a better job then I'm afraid I'm not aware of them, this question might be more suited to ServerFault, the above is a much more developer-ish approach to troubleshooting :-p)

    0 讨论(0)
  • 2021-02-05 17:20

    I've just been battling a similar issue. For me it turned out to be that I had enabled internal logging for NLog. It added about 3 minutes to the startup time!

    Original config

    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          autoReload="true"
          throwExceptions="false" throwConfigExceptions="false"
          internalLogLevel="Debug"
          internalLogFile="C:\Temp\NLog.Internal.txt">
    

    Fixed Config

    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          autoReload="true"
          throwExceptions="false" throwConfigExceptions="false">
    

    For Info I discovered this by using SysInternals' ProcMon.exe, filtering on the Process Name "w3wp.exe"

    0 讨论(0)
  • 2021-02-05 17:25

    This hat nothing to do with JIT compiling. The normal C# compiler compiles your code behind files (.aspx.cs) into intermediate language into an assembly at startup if this assembly dont exist or code files have changed. Your web site assembly is located in the "bin" folder of your web site.

    In fact the JIT compiling occures after that, but this is very fast and won't take several minutes. JIT Compiling happens on every startup of an .net application and that won't take more than a view seconds.

    You can avoid the copmpiling of your web site if you deploy the already compiled website assembly (YourWebsite.dll) into the bin folder. It is also possible to deploy only the aspx files and leave the code behind files (aspx.cs) files away.

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