Question

I have a WCF service that requires a certain response time (under 1 minute).

My problem is that every so often, most often in the mornings the service takes a long time to respond (sometimes over 2 minutes).

I'm thinking this is because the app has recycled and the first run must recompile.

Are there other reasons this might happen?

Is it possible to turn off app recycling? And if it is, will that cause any side effects or instability? I'm assuming there must be a reason why asp.net apps are set to recycle.

Is there anything else that can be done to improve that first run performance?

Was it helpful?

Solution

Basically the following rules dictate when an application is recycled or unloaded:

  1. After the App Pool Recycle time has been reached - by default this is every 29 hours I think.
  2. A set time after the last request to application.

Using a keep-alive to ping the service would solve 2, and then you'd just have to deal with 1.

Depending on your version of IIS, there are slightly different ways to configure this.

  1. For IIS 6
  2. For IIS 7

The idle time out I think would normally default to "infinte", but can be configured through the processModel element (idleTimeout attribute) of your configuration files.

As to first run performance - without looking at your app it's hard to say, have you run something like DotTrace or another profiler over it?

Are you doing a lot of intensive lookups and caching data in that first load? Can these be deferred?

OTHER TIPS

Yes you can prevent the AppPool from recycling. Another option would be to create a keep-alive job to continually ping the service to keep the worker process from sleeping.

Performance problems can be caused by anything you haven't ruled out first. Since you haven't ruled anything out, it could be cauased by anything at all.

Maybe a silly idea : could you schedule a console app to hit your service at e.g. 5:30am in the morning, so that this request would take a long time to run, and your regular users coming in after that won't have that problem?

Sure - it's not dealing with the root cause, but for the time being, it might be a useful workaround - no?

Marc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top