Mvc icon indicating copy to clipboard operation
Mvc copied to clipboard

Slow performance on IIS 8.0

Open 82dsoldier opened this issue 10 years ago • 13 comments

I have built an application and deployed it to IIS 8.0. On my local machine running IIS Express, each page responds instantly. However, when deployed to the web server, each page takes about 30 seconds to load. Both instances are using the same database. This is not just the initial page view, this is every page that I load.

I don't know what other information you need, but I'll be glad to gather anything that I can.

82dsoldier avatar May 03 '16 14:05 82dsoldier

@82dsoldier we definitely have not seen this before. Can you enable some IIS logging to see what IIS module is taking all the time? Or if the slowdown is entirely in ASP.NET Core, you could enable ASP.NET Core's Verbose Logging to gain more insight about what's taking so long. Or even run a tool such as https://www.jetbrains.com/profiler/ (free trial) to see what is taking so long.

@Tratcher do you have any other suggestions on how to diagnose this?

Eilon avatar May 05 '16 20:05 Eilon

Where is your IIS instance? On the same machine? In a data center? Are you running multiple instances?

Tratcher avatar May 05 '16 21:05 Tratcher

@Eilon Unfortunately, I am working in a nuclear facility and am not allowed to use products by JetBrains. I'll have to figure out how to enable logging to give you anything more on that. What IIS logging do I need to enable?

@Tratcher The IIS instance is on a separate Windows 2012 server. It is running as a virtual machine on an HP blade system. There is only one instance on this machine.

82dsoldier avatar May 06 '16 12:05 82dsoldier

In your web.config set: <aspNetCore ... stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />. Make sure the logs folder exists.

Tratcher avatar May 06 '16 20:05 Tratcher

Here is one of the requests that takes so long. I have no idea why it's referring to a key as I don't use encryption anywhere at this time.

info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
      Request starting HTTP/1.1 GET http://asmt/Applications/EditMain/289  
verb: Microsoft.AspNet.StaticFiles.StaticFileMiddleware[4]
      The request path /Applications/EditMain/289 does not match a supported file type
verb: Microsoft.AspNet.Routing.Template.TemplateRoute[0]
      Request successfully matched the route with name 'default' and template '{controller=Home}/{action=Index}/{id?}'.
verb: Microsoft.AspNet.Mvc.Infrastructure.DefaultActionSelector[0]
      Action 'ASMT.Controllers.ApplicationsController.EditMain' with id 'c35bc60e-9ccd-4835-99a2-22271833f276' did not match the constraint 'Microsoft.AspNet.Mvc.ActionConstraints.HttpMethodConstraint'
verb: Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler[1]
      Executing action ASMT.Controllers.ApplicationsController.EditMain
info: Microsoft.AspNet.Mvc.Controllers.ControllerActionInvoker[1]
      Executing action method ASMT.Controllers.ApplicationsController.EditMain with arguments (289) - ModelState is Valid'
verb: Microsoft.AspNet.Mvc.Controllers.ControllerActionInvoker[2]
      Executed action method ASMT.Controllers.ApplicationsController.EditMain, returned result Microsoft.AspNet.Mvc.ViewResult.'
verb: Microsoft.AspNet.Mvc.ViewFeatures.ViewResultExecutor[0]
      The view 'EditMain' was found.
info: Microsoft.AspNet.Mvc.ViewFeatures.ViewResultExecutor[1]
      Executing ViewResult, running view at path /Views/Applications/EditMain.cshtml.
verb: Microsoft.AspNet.DataProtection.KeyManagement.DefaultKeyResolver[0]
      Repository contains no viable default key. Caller should generate a key with immediate activation.
verb: Microsoft.AspNet.DataProtection.KeyManagement.KeyRingProvider[0]
      Policy resolution states that a new key should be added to the key ring.
info: Microsoft.AspNet.DataProtection.KeyManagement.XmlKeyManager[0]
      Creating key {9466528c-e7ca-49db-93d5-7c8a825c4d70} with creation date 2016-05-09 12:43:00Z, activation date 2016-05-09 12:43:00Z, and expiration date 2016-08-07 12:43:00Z.
verb: Microsoft.AspNet.DataProtection.KeyManagement.XmlKeyManager[0]
      Descriptor deserializer type for key {9466528c-e7ca-49db-93d5-7c8a825c4d70} is 'Microsoft.AspNet.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNet.DataProtection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
verb: Microsoft.AspNet.DataProtection.KeyManagement.XmlKeyManager[0]
      No key escrow sink found. Not writing key {9466528c-e7ca-49db-93d5-7c8a825c4d70} to escrow.
warn: Microsoft.AspNet.DataProtection.KeyManagement.XmlKeyManager[0]
      No XML encryptor configured. Key {9466528c-e7ca-49db-93d5-7c8a825c4d70} may be persisted to storage in unencrypted form.
verb: Microsoft.AspNet.DataProtection.KeyManagement.XmlKeyManager[0]
      Key cache expiration token triggered by 'CreateNewKey' operation.
verb: Microsoft.AspNet.DataProtection.KeyManagement.XmlKeyManager[0]
      Found key {9466528c-e7ca-49db-93d5-7c8a825c4d70}.
verb: Microsoft.AspNet.DataProtection.KeyManagement.DefaultKeyResolver[0]
      Considering key {9466528c-e7ca-49db-93d5-7c8a825c4d70} with expiration date 2016-08-07 12:43:00Z as default key.
verb: Microsoft.AspNet.DataProtection.AuthenticatedEncryption.ConfigurationModel.CngCbcAuthenticatedEncryptorDescriptor[0]
      Opening CNG algorithm 'AES' from provider '' with chaining mode CBC.
verb: Microsoft.AspNet.DataProtection.AuthenticatedEncryption.ConfigurationModel.CngCbcAuthenticatedEncryptorDescriptor[0]
      Opening CNG algorithm 'SHA256' from provider '' with HMAC.
verb: Microsoft.AspNet.DataProtection.KeyManagement.KeyRingProvider[0]
      Using key {9466528c-e7ca-49db-93d5-7c8a825c4d70} as the default key.
dbug: Microsoft.AspNet.DataProtection.KeyManagement.KeyRingBasedDataProtector[0]
      Performing protect operation to key {9466528c-e7ca-49db-93d5-7c8a825c4d70} with purposes ('D:\ASMT\approot\packages\ASMT\1.0.0.5\root', 'Microsoft.AspNet.Antiforgery.AntiforgeryToken.v1').
dbug: Microsoft.AspNet.DataProtection.KeyManagement.KeyRingBasedDataProtector[0]
      Performing protect operation to key {9466528c-e7ca-49db-93d5-7c8a825c4d70} with purposes ('D:\ASMT\approot\packages\ASMT\1.0.0.5\root', 'Microsoft.AspNet.Antiforgery.AntiforgeryToken.v1').
dbug: Microsoft.AspNet.DataProtection.KeyManagement.KeyRingBasedDataProtector[0]
      Performing protect operation to key {9466528c-e7ca-49db-93d5-7c8a825c4d70} with purposes ('D:\ASMT\approot\packages\ASMT\1.0.0.5\root', 'Microsoft.AspNet.Antiforgery.AntiforgeryToken.v1').
info: Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler[2]
      Executed action ASMT.Controllers.ApplicationsController.EditMain in 0.2293ms
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2]
      Request finished in 0.2309ms 200 text/html; charset=utf-8
dbug: Microsoft.AspNet.Server.Kestrel[9]
      Connection id "3" completed keep alive response.
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
      Request starting HTTP/1.1 GET http://asmt/js/popup.min.js  
info: Microsoft.AspNet.StaticFiles.StaticFileMiddleware[6]
      The file /js/popup.min.js was not modified
verb: Microsoft.AspNet.StaticFiles.StaticFileMiddleware[8]
      Handled. Status code: 304 File: /js/popup.min.js
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2]
      Request finished in 0ms 304 application/javascript

82dsoldier avatar May 09 '16 13:05 82dsoldier

:warning: Wall of Text Alert! :warning:

@82dsoldier Mind wrapping that in log in a fenced code block (```)?

khellang avatar May 09 '16 13:05 khellang

That claims your request only took 0.2309ms to execute, so either the request took a long time to reach the server, or the server is taking a long time to start (and restarting every time for some reason).

Tratcher avatar May 09 '16 14:05 Tratcher

@Tratcher How would I tell if the server is restarting every time?

82dsoldier avatar May 09 '16 19:05 82dsoldier

Run two requests and see if the log has the startup messages (e.g. "Now listening on...") repeated.

Tratcher avatar May 09 '16 19:05 Tratcher

My server isn't restarting. Could this be an issue with Kestrel passing the information back to IIS before passing it back to the client? Is there any way I can check that?

82dsoldier avatar May 17 '16 19:05 82dsoldier

@Tratcher ?

Eilon avatar May 20 '16 05:05 Eilon

IIS has its own logging system you could check. https://www.iis.net/configreference/system.webserver/httplogging

Tratcher avatar May 20 '16 22:05 Tratcher

Thanks for your help with this. I ended up running the kestrel server beside the IIS server instead of behind and did some testing that way. For some reason the delay appears to be happening during the rendering in IE. I'll have to tear the site apart to see what's happening, but at least I've eliminated the server itself.

82dsoldier avatar May 21 '16 12:05 82dsoldier