13

Simple noob question :-)

I'm about to go into production with a small .NET core app host that's hosted in a droplet at digitalocean. I've always hosted websites using IIS, but I would like to move to linux distributions and use nginx as reverse proxy.

My question is as the title says :-) Does kestrel every need to recycle a "application pool" like the IIS does? If not, does that mean the application is loaded from Kestrel is online until it's shut down?

Best regards Jens

RonC
  • 31,330
  • 19
  • 94
  • 139
dev1985
  • 171
  • 1
  • 8
  • 1
    Suggestion: Kestrel sucks, don't use it without IIS or some other process management layer to keep it alive – A X Feb 27 '21 at 17:53

1 Answers1

11

Based on bits of information here and there from watching all the http://live.asp.net Community Standup meetings I'd so no, Kestrel does not recycle itself the way IIS does.

The reason for this is that Kestrel currently has no way to restart itself if it stops. That's one of the many reasons why it's important to put it behind some sort of reverse proxy like IIS or nginx. This kind of process lifetime management functionality must currently come from a software layer outside of Kestrel. If Kestrel dies due to a software bug or other reason and there is no reverse proxy or other process to restart it, it will not restart by itself and the website will be stay down.

For additional information, this article talks about Publishing to a Linux Production Environment and includes an example nginx system service file that has Restart=always https://learn.microsoft.com/en-us/aspnet/core/publishing/linuxproduction

TN.
  • 18,874
  • 30
  • 99
  • 157
RonC
  • 31,330
  • 19
  • 94
  • 139
  • 1
    It's sad that there is no built-in solution and I haven't yet found a de-facto standard alternative (should have been documented by Microsoft) for Linux. The main difference is that IIS app pool restarts preventively, to clean up any accumulated memory etc. If there is no similar mechanism implemented for Kestrel on Linux, then it might accumulate memory debris until it slows down to a crawl (because of using swap file instead of RAM) and finally crashes. So, on Linux we'd need additional utility (cron job?) to do scheduled restarts. However, Microsoft documentation neglects to mention this. – JustAMartin Sep 01 '20 at 07:59
  • @JustAMartin - That's an interesting point. I would have thought that nginx would have a setting for process recycling, so that you could periodically recycle kestral. But I did a bit of googling and didn't see such a setting. If that's a feature you need you should probably post it as a nginx question here on SO. Perhaps someone with more experience with nginx can shine light on a solution. – RonC Sep 01 '20 at 14:15
  • I'm afraid there won't be any out-of-the-box solution for Nginx because it acts just as a dummy proxy. Nginx routes data from/to network socket or Unix pipe and doesn't care if it's Kestrel or anything else at the other end; unlike IIS which is tightly integrated with .NET Core hosting mechanisms. So, I guess, on Linux we are totally in "do it yourself" area. – JustAMartin Sep 01 '20 at 20:25