I have multiple web services (WCF) running in IIS. When the services are warm (loaded), typical requests take about 0.5 seconds to complete. However, when the application is not warm (cold start), the first hit takes some 20 seconds before the service is up and running. The same happens when an app pool recycle occurs.
I'm looking to reduce the cold start times for this web service. Some actions i have already performed are:
Configured the application pool so that it doesn't recycle after 20 min, idle time (so that the application stays warm). This minimizes the occurence of cold starts, but doesn't make cold starts faster. app pool recycles are now limited, but do stil occur.
Modified the machine.config,
like this:
<runtime>
<!-- see http://msdn.microsoft.com/en-us/library/bb629393(v=vs.90).aspx -->
<generatePublisherEvidence enabled="false"/>
</runtime>
This reduces startup times from 20 secs to about 10 secs.
NGEN
to precompile the assemblies,like this
for %d in (*.dll) do ngen install %d
This doesn't reduce startup times (only adds complexity to deployment).
I would really like to reduce the cold start times even further. What options do i have to do this?
(on a side note: what is the best way to find out where the time is spend during startup? how do i monitor what's going on?)
To make your ASP.NET applicationstart up faster, simply upgrade your server to ASP.NET 4.5. If you want to turn Multicore JIT off in your ASP.NET 4.5 applications, use the new profileGuidedOptimizations flag in the web.config file as follows:
You can apply a fix for the slow start times by editing some values for the site from IIS Manager. There's a good reason why IIS terminates apps that have not had any recent activity.
ASP.NET Core apps with complex front-ends frequently serve many JavaScript, CSS, or image files. Performance of initial load requests can be improved by: Bundling, which combines multiple files into one. Minifying, which reduces the size of files by removing whitespace and comments.
Large managed applications require JIT (just-in-time) compilation at launch time, so improving launch performance can be challenging. . NET Framework developers have been able to use Ngen.exe (Native Image Generator) to move code generation from application startup time to installation time.
I've done some further testing with procmon
. There doesn't seem to be one single cause of the start up time, it's a whole lot of little timeslices (proces start, loading ,net runtime, reading configuration, loading assemblies, etc..) that add up to the total time.
I've had decent luck with the strategy found in this article. It keeps the application alive so that once it's running, you just won't have any cold starts (unless IIS or the machine is actually restarted intentionally or as the result of a significant error). The app keeps itself alive regardless of any activity.
The article is about scheduling something to happen every so-often, but you can skip that part if your only goal is to keep the app alive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With