First request takes long time – assembly unloading

As you might experienced, the first time you make a request to a web service exposed by BizTalk, the response can take a really long time, sometimes over a minute. This is becuase assemblies are unload after a certain time of inactivity. You can change this time, but you have to do it in two places.
 
One is the IIS worker process. Select properties on the application pool you are using, then select the Performance tab and adjust idle timeout.
 
IdleTimeout
The other one is the orchestration engine. You must edit the BTSNTSvc.exe.config file. Add the following:
 
    <configSections>
        <section name="xlangs" type="Microsoft.XLANGs.BizTalk.CrossProcess.XmlSerializationConfigurationSectionHandler, Microsoft.XLANGs.BizTalk.CrossProcess" />
    </configSections>
 
and
 
    <xlangs>
        <Configuration>
            <!–
                AppDomain configuration.
                Assemblies are assigned to named domains using assignment rules (see more below).
                If no rule is specified for some assembly, the assembly will be assigned to an ad hoc domain.
                The number of such assigned assemblies per ad hoc domain is determined by the value of AssembliesPerDomain.
             –>
            <AppDomains AssembliesPerDomain="10">
                <!–
                In this section the user may specify defualt configuration for any app domain created
                that does not have a named configuration associated with it (see AppDomainSpecs below).
                SecondsEmptyBeforeShutdown is the number of seconds that an app domain is empty
                (that is, it does not contain any orchestrations) before being unloaded.
                Specify -1 to signal that an app domain should never unload, even when empty. Default is 1200.
                Similarly, SecondsIdleBeforeShutdown is the number of seconds that an app domain is idle
                (that is, it contains only dehydratable orchestrations) before being unloaded.
                Specify -1 to signal that an app domain should never unload when idle but not empty.
                When an idle but non-empty domain is shut down, all of the contained instances are dehydrated first.
                Default is 1800.
                –>
                <DefaultSpec SecondsIdleBeforeShutdown="14400" SecondsEmptyBeforeShutdown="14400"/>
            </AppDomains>
        </Configuration>
    </xlangs>
For more details, read the MSDN Orchestration Engine Configuration article. Note that the example configuration file contains errors.
Also note that the default for SecondsIdleBeforeShutdown is 1800 and default for SecondsEmptyBeforeShutdown is 1200, not the other way around.
 
 
 
Advertisements