IIS 7.5 Application Initialization for ASP.NET web service (warmup) without remapping requests
Asked Answered
L

1

20

I'm trying to use the IIS 7.5 Application Initialization extension to configure a warmup process for my web application. This is an approach I am taking to minimize slow downs caused by application pool recycling, which is a problem explained well in other questions on Stack Overflow.

What I would like, is to gain the benefits of application initialization, without remapping requests anywhere else.

What I've done so far

I followed the IIS 8 instructions for the basic use case, and it works great! I created a splash page called app_starting.htm and by using this code, it gets displayed while the app initializes:

<applicationInitialization remapManagedRequestsTo="app_starting.htm" skipManagedModules="true" >
    <add initializationPage="/" />
</applicationInitialization>

Why this isn't good

I want to use initialization to speed up requests to a REST-based web service written using ASP.NET MVC. This web service is a backend for several applications. When they make a request to a resource (i.e. /client/1/addresses), they can't handle receiving a splash page instead.

What I've tried

I removed the remapManagedRequestsTo attribute. However, now when I request a resource during initialization, I get a 500 error until initialization is completed. After which, responses go back to normal. The applications which rely on this this service also wouldn't respond well to a 500 error, since initialization should not be an error condition.

What I need

Without performing any remapping, I expect the request behavior to go back to normal. Even if initialization is in progress, other requests to the application should be queued and wait until after initialization has completed.

Is there something I am missing? Can I accomplish this?

Thanks for the help!

Leighleigha answered 11/3, 2013 at 21:6 Comment(0)
L
29

I think I answered my own question. I removed the skipManagedModules attribute and it worked. This code accomplishes application initialization, and during warmup, requests seem to wait for it to complete before being processed:

<applicationInitialization>
    <add initializationPage="/" />
</applicationInitialization>

I couldn't find any documentation for why it behaves this way and don't really understand what skipManagedModules means. If anyone can further explain this, I can mark the explanation as an answer. Thanks!

Leighleigha answered 12/3, 2013 at 17:8 Comment(5)
Jason I was wondering what version of Windows you are using here? I am trying to set up Application Initialization on a 2008 r2 / IIS 7.5 and am having a good deal of issues. Thanks!Sri
That's exactly what I am using! I also have configured it on my Win7 x64 workstation for development. Have you installed the extension? IIS 8 comes with this feature but it must be installed on 7.5.Leighleigha
I had a couple of issues. The module was missing from the applicationHost.config after the extension install and we're running SSL. I'm still working around the SSL issue. This all would be easier if I was using IIS 8 but alas that's not an option.Sri
Ok, yes, the applicationHost.config is not configured by the install. Regarding SSL, we use it too, but I don't use the "Require SSL" flag. Instead I use URL Rewrite to redirect to HTTPS for all except localhost requests. Then I can get the local warmup to work correctly...Leighleigha
Is that code mean when you start some website, it will auto send request to "/" ? which mean first request will auto send? because that's what I want, I don't want to wait user send first request or IIS cycle time finish.Cession

© 2022 - 2024 — McMap. All rights reserved.