Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS randomly Restarts Dotnet core apps

So in production, all my dotnet core apps hosted in IIS 8 (Windows server 2012 R2) restarts at random times during the day. About once a day. Never at the same time - random times. I've got many users hitting this in production, as well as scheduled services failing, etc... In the end this restart causes donwtime (my main service takes about 5 minutes to start up, since it's getting hammered with requests, etc) everyday, which is obviously unacceptable.

In the event viewer, there is nothing preceding the restarts - there's only the one-liner for each service:

Information - Timestamp - IIS AspNetCore Module - 1001 - None

With details: Process '9652' started successfully and is listening on port '25405'.

For every single dotnet core app (dotnet 1.0.0 - netcoreapp1.0) I have. Sometimes the application fails after first try, probably because its getting too many hits, or something, which just makes the downtime longer.

There is no IIS or dotnet crash dumps (I enabled crash dumps through WER). There's nothing of help in the application logs, nothing in IIS logs... I switched on the STDOUT logs as well - nothing of help around time of restart.

Version of dotnet core on the server: .NET Core 1.0.1 - SDK 1.0.0 Preview 2-003133 (x64) - not that I think dotnet's the culprit, since it's IIS doing the restart...

What can I do to find out why my apps are crashing?

like image 961
Johan Foley Avatar asked May 22 '17 17:05

Johan Foley


1 Answers

As per Henry's answer - it was a setting on recycling that caused my nightmares. On IIS 8 there is an Advanced Setting of the AppPools for Recycling at Regular Time Intervals (minutes) which was by default set to 1740 (29 hours). So I changed this to 0 (never recycle).

Problem is when IIS recycles the App Pools, it actually restarts your dotnet core apps. Which is not ideal in certain scenarios (for example when you have many users sending requests to your restarting application).

Will monitor the applications' performance, and if necessary make use of the 'Specific Times' option to restart all the .net core apps outside of business hours.

like image 73
Johan Foley Avatar answered Nov 10 '22 12:11

Johan Foley