Search code examples
asp.net-coregoogle-cloud-platformgoogle-compute-engineprogram-entry-point

Compute Engine reason for application recycling


I have setup logging for my ASP.NET Core enabled Compute Engine Instance. I find that at seemingly random times, the public static void Main(string[] args) method is re-entered. I have been told that this is due to application recycling.

Is this behaviour a result of my code failing? Is it scheduled? and how do I prevent it/determing the cause?

Thanks


Solution

  • Is this behaviour a result of my code failing?

    No, this is normal housekeeping by IIS. Your app is idle and IIS has decided to release and restart your application. One of the reasons is to free up memory. Another is preventing memory leaks from slowly consuming all memory.

    Is it scheduled?

    This is controlled by Idle Timeout. You can make this longer or shorter. I don't recommending changing this setting. Think about why you need your program to run when nothing is happening (it is idle).

    and how do I prevent it/determing the cause?

    You can disable recycling or delay it by changing Idle Timeout.