Search code examples
asp.netazurepublishingapplication-start

ASP.net publishing project is slow to start


I have a fairly large website (~75k LoC), deployed two D2 v2 machines on Azure (7GiB RAM, 2 VCPU).

When I do a new build, I observe:

  • 1 of the CPUs going to 100%
  • This lasts for up to two minutes
  • Then Application_Start is fired

I'm trying to improve the time from when I publish to when Application_Start is fired as we publish regularly and it does cause some pain for visitors on the site.

Publishing the site consists of:

  • Publishing to folder (File System publish method)
  • Configuration Release
  • Delete all existing files checked
  • Precompile during publishing checked
  • Exclude files from App_Data folder checked
  • In advanced precompile settings, nothing is checked or selected except Do not merge in merge options
  • Zip the published folder up, upload to the VM's and unzip overwriting existing files (takes only a few seconds)

My question is:

  • Is the initial hold up in the realm of normal, or is there anything I can do to measure what it's doing?
  • Is there any settings I can change to improve time to reach the Application_Start event?

Solution

  • What you are seeing is IIS starting up the application pool and it is normal for this to take awhile, especially if the site is large. The startup time is primarily limited by the hardware- as you are seeing one of the CPU cores reaching 100% that is your bottleneck.

    As you have two web servers the best way to deal with this would be to deploy to one server and then wait for it to come back online before deploying the second. Sending a warm up request after deployment will ensure that IIS starts up as quickly as possible.