Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIS Idle Timeout #12232

Closed
sebastienricher opened this issue May 1, 2019 — with docs.microsoft.com · 16 comments · Fixed by #12389
Closed

IIS Idle Timeout #12232

sebastienricher opened this issue May 1, 2019 — with docs.microsoft.com · 16 comments · Fixed by #12389
Assignees
Labels
Pri1 High priority, do before Pri2 and Pri3 Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

I have hosted services running in process on IIS, do these refresh the IIS idle timeout?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added the Source - Docs.ms Docs Customer feedback via GitHub Issue label May 1, 2019
@guardrex
Copy link
Collaborator

guardrex commented May 1, 2019

@sebastienricher ... for the most recent 👊 bar brawl 👊 convo, see dotnet/aspnetcore#3849 ....... it's a knife 🔪 fight in there 😄, so be ready. Do feel free to add your own feedback. The engineers do take your feedback into consideration as they design and implement scenarios for the framework.

  • Use the Application Initialization Module (2.2+ with in-proc hosting). Always running + idle timeout set to 0 (zero) + preload enabled. Engineering says 'it works' with 2.2 or later and in-proc hosting.
  • Use an external ping service to hit the app periodically (inside the idle timeout) to keep it warm.
  • Move the scenario to a Windows Service.
  • I think someone said this works ... try the Health Check Publisher ... but note that there's a small issue with it until 3.0 (there's a note in the topic to explain the problem). Let me know if you try it and it does or does not work.
  • I see a PS script thingy that someone did on that engineering issue, too, that issues pings to the app.

Leave this open @sebastienricher ... I'd like to add a section that lays out the options or goes with whatever the engineers prefer that devs use. There will be a delta (probably) for in-process vs. out-of-process (i.e., out-of-process probably works with the external ping the best), and I'd like to get that difference covered, too.

@guardrex guardrex self-assigned this May 1, 2019
@guardrex guardrex added the Pri1 High priority, do before Pri2 and Pri3 label May 1, 2019
@guardrex guardrex added this to the 2019 Q2 ends June 30 milestone May 1, 2019
@sebastienricher
Copy link
Author

Sounds good, I can chime in with the final selection when I have it. One thing that might be to consider also is the Application Pool's .NET CLR Version, in the current tests I'm running, I have it set to No Managed Code.

@guardrex
Copy link
Collaborator

guardrex commented May 2, 2019

That's correct ... the CoreCLR is is booted to host the app in the worker process. You should be able to leave that set just like you have it and the methods that I listed should work. 🤞🍀 ... don't forget to sacrifice a Microsoft mouse to the 🙏 server gods 🙏. 😄 ... it couldn't hurt. 😄

When I get to this issue, I'll see about clarifying the app pool .NET CLR version setting in one or two other spots. Right now, it's only directly covered in the IIS set up instructions (and it doesn't say why one is setting it that way) ...

https://docs.microsoft.com/aspnet/core/host-and-deploy/iis/#create-the-iis-site

Of course, it doesn't matter (much) if it's set. There might be a very VERY tiny penalty of like microseconds on server start/app pool recycle to have it set AFAIK from talking to the engineers, but I think the language could use a tiny touch of work to clarify it.

@sebastienricher
Copy link
Author

Good news, I tried "Always running + idle timeout set to 0 (zero) + preload enabled.", initial tests are positive! I'll drill it some more but both my site seems to be staying warm and the hosted services keep running every 15 minutes. Thanks for pointing me in the good direction!

@guardrex
Copy link
Collaborator

guardrex commented May 2, 2019

Cool ... did you test an app pool recycle, too? Also ... and similar to a recycle, did you test a total server restart? Does the app get up and running without intervention? [EDIT] Sorry ... I meant to say that the Application Initialization Module should get it started in these scenarios, too.

@sebastienricher
Copy link
Author

You're right, that's what I'm seeing now. Once the Application is actually started it does not go to sleep as wanted, but when there is a recycle, it does not come back up on it's own.

I'll look into the initialization module, it seems to be the reliable way to go about this from both your indications and related posts.

@guardrex
Copy link
Collaborator

guardrex commented May 2, 2019

Check and confirm that the server role feature for Application Initialization is enabled.

@guardrex
Copy link
Collaborator

guardrex commented May 2, 2019

@guardrex
Copy link
Collaborator

guardrex commented May 2, 2019

According to IIS's docs, it should ✨ Just Work™️ ✨. I need to dig into the subject a bit more and perform some testing here, too. I'm buried in file upload code at the moment, but I should be free (free-ish 🏃😅) within two weeks to take a deeper look.

My impression of the most reliable way to keep an IIS-based ASP.NET Core app started and warm is .... drum roll plz .... 🥁🥁🥁🥁🥁 .... external service pings. ei ei ei ... I know ... I know. That's not good. I just say that because I've seen this come up over-and-over for two years now and the devs who say that they use an external service to ping their apps seem to live with the least stress in their lives.

@guardrex
Copy link
Collaborator

guardrex commented May 2, 2019

..... well .... I'll add this to that .... the devs who moved their always-running service things to a Windows Service also seem very happy. Consider that option, too. Get your always-must-run-ALWAYS! stuff off of IIS. That's a good option, too.

@sebastienricher
Copy link
Author

sebastienricher commented May 3, 2019

Yeah I need IIS for internal certificate and infrastructure reasons, but it is a viable last recourse.

I'm all setup with application initialization, but I'm still not getting warmed up.

Added this to web.config:

  <applicationInitialization doAppInitAfterRestart="true">
    <add initializationPage="/api/bfm/healthcheck/" />
  </applicationInitialization>

Also using https://serverfault.com/questions/590865/how-can-i-warm-up-my-asp-net-mvc-webapp-after-an-app-pool-recycle/595215#595215 as reference.

@guardrex
Copy link
Collaborator

guardrex commented May 3, 2019

I'm surprised that the preload setting doesn't do it.

Setting preloadEnabled to "true" tells IIS 8.0 that it sends a "fake" request to the application when the associated application pool starts up.

I'll mark this issue with the PU label, but I might get to it before engineering takes a look. In that case, I'll do the best I can (and do my own testing here as you're doing there). If the PR goes in before they look at this issue, then they'll be pinged to review the PR, and that should lead to final answers on guidance. They might get to looking at "PU"-labelled issues soon now that Preview 4 is out.

@guardrex guardrex added the PU label May 3, 2019
@sebastienricher
Copy link
Author

As a reference, I'm running on HTTPS, so I am looking here for part of the solution also: https://support.microsoft.com/en-ca/help/2843964/application-initialization-module-fails-when-web-site-requires-ssl

@sebastienricher
Copy link
Author

"fake" request

Do we know what URL is used for that? This would be subject to the site's bindings?

@guardrex
Copy link
Collaborator

guardrex commented May 3, 2019

Good question ... we need PU (product unit) support. Now that I've marked this issue, engineering (shiratti) will see it and respond. Alternatively, I'll work the issue and get a PR up. He'll review and help at that point. We're a bit limited on pinging him here because he's quite 🏃😅 busy most of the time. I'll get back to this asap. It's a top item for May, so I think I'll get to it next week.

@guardrex
Copy link
Collaborator

@sebastienricher It looks like the answer is yes to your suggestion on the binding port ... and it goes to /.

The applicationInitialization element tells IIS that it should issue a request to the application's root Url ("/" in this example) in order to initialize the application.

I'll be working this one very soon, including some local testing to see what's what with my own 👀. I'll ping u on the PR when it goes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pri1 High priority, do before Pri2 and Pri3 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants