Search code examples
asp.net.netdockeriisrecycle

NET. 6 on Docker Container and Application Pool Recycle


I am developing an application on .NET6 using Microsoft Blazor. I have containerized this application to be able to deploy with more flexibility and to avoid Azure Web Apps problems.

Azure Web Apps is an Azure service which can host web applications like .NET 6 applications but while running on this service, several things can happen:

  1. Server Swap, service is changing the underlying infrastructure, this can be avoided by using the ARR AFFINITY switch form the Azure Portal
  2. Server Upgrades, framework or storage upgrades causes application to be restarted at any time
  3. Application Pool recycle with periodic recycle intervals

So when we have an application which has a stateful mechanism such as a thread pool, all the treads will be cleared after the application is restarted.

Here is an example of a random restart: enter image description here

One cool way that I found to overcome these issues, is by using Docker Containers which they can implement the .NET 6.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

I have already tested this and my application is running without any problem or restart for a week by now while in Azure I had at least two restarts inside a week.

My concern now is more about Application Pool recycle, I was familiar in the past with IIS but now I am sure how this is handled in docker container, if there is an IIS behind with settings and if there is, how I can check the 'DisableOverlappedRecycle', 'DisableRecyclingConfigChange' and 'Idle Time-out' options.

Any ideas?


Solution

  • Looking inside the running Docker container which build by the Dockerfile to understand the deployment, found the project files but also the Web.config file.

    That means that an IIS is running, which can accept several settings there like DisableOverlappedRecycle', 'DisableRecyclingConfigChange' and 'Idle Time-out' options.