10
votes

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.

  • I've tried using 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?)

2
What version of IIS? Can you install AppFabric? - BrandonZeider
IIS 6 on Windows 2003. How can AppFabric help with startup times? - oɔɯǝɹ
AppFabric has an auto start feature will prevent the warm up delays. Here's a blog post for you, but this is only available in IIS 7.5., so it won't help you any. If you can't use AppFabric, consider self hosting your WCF services. blogs.msdn.com/b/appfabriccat/archive/2010/10/29/… - BrandonZeider
If you decide to go the self hosting route, check out ECollective: soacollective.com/solutions/ecollective/ecollective-features - BrandonZeider

2 Answers

2
votes

Update

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.

1
votes

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.