Search code examples
asp.netwcfperformancerecycleapplication-pool

asp.net WCF service slow... will disabling asp.net app recycling help?


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?


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?