views:

1228

answers:

4

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?

+2  A: 

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.

Andrew Hare
A: 

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.

John Saunders
Are there any common issues I should look at? Right now I'm thinking it's the app pool recycle since the issue happens around the time the app pool would recycle. Plus the WCF service calls other services that have the same recycle setting and I can see their response times jump all at around the same time of day.
metanaito
I should add that we looked at traffic and the performance of the server and have not seen any spikes in traffic when the service takes a long time.
metanaito
If you can confirm that the App Pool actually does recycle near the time that the performance spike occurs, then you won't be making an assumption - you'll know.
John Saunders
A: 

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

marc_s
+1  A: 

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?

Zhaph - Ben Duguid