Why does the IIS worker process recycling every 29 hours, why default value of this is so odd
Loading
Why does the IIS worker process recycling every 29 hours, why default value of this is so odd
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajkiran SwainRank #165 · 14.4K reputationPosted Apr 24, 2023, 8:13 AM EDT
The default value for the IIS worker process recycling interval of 29 hours may seem odd, but there is a reason behind it.
The purpose of recycling the worker process is to help maintain the stability and reliability of the web server. Over time, the worker process can accumulate memory leaks, fragmentation, and other issues that can impact performance and cause errors. Recycling the worker process periodically helps to mitigate these issues and keep the web server running smoothly.
The default recycling interval of 29 hours is intended to strike a balance between the need for periodic recycling and the desire to minimize disruptions to users. By default, IIS will recycle the worker process at a time that is least likely to impact users, typically during low-traffic periods such as the early morning hours.
Vishal YelveRank #178 · 13.6K reputationPosted Apr 25, 2023, 12:53 AM EDT
Hi Abhishek,
Do refer below links
https://www.c-sharpcorner.com/blogs/resolve-iis-a-worker-process-has-requested-a-recycle-issue
https://weblogs.asp.net/owscott/why-is-the-iis-default-app-pool-recycle-set-to-1740-minutes
https://serverfault.com/questions/348493/why-does-the-iis-worker-process-recycle-every-29-hours-and-not-every-24-hours#:~:text=had%20a%20reason-,The%20reason%20that%20IIS6%20recycles%20every%2029%20hours%20by%20default,literally%20needs%20to%20restart%20frequently.
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 25, 2023, 2:16 AM EDT
The IIS worker process is set to recycle every 29 hours by default to prevent memory leaks and other issues that can arise from long-running worker processes. When a worker process recycles, it releases any resources it was holding onto, which can help prevent problems that might occur if the process continued running indefinitely.
One use case where this default setting is helpful is in hosting web applications that use a lot of memory or have long-running processes. If the worker process were allowed to run indefinitely, it could consume all available memory on the server and cause other applications to fail or become unresponsive. By recycling the process every 29 hours, the server can ensure that resources are being used efficiently and that any potential issues are caught before they become serious problems.
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 11, 2024, 6:55 AM EDT
code snippet that demonstrates how to change the recycling interval of an application pool
using System; using Microsoft.Web.Administration; class Program { static void Main(string[] args) { string appPoolName = "YourApplicationPoolName"; TimeSpan recyclingInterval = TimeSpan.FromHours(29); // Set the desired recycling interval try { using (ServerManager serverManager = new ServerManager()) { ApplicationPool appPool = serverManager.ApplicationPools[appPoolName]; if (appPool != null) { // Set the recycling interval for the application pool appPool.Recycling.PeriodicRestart.Time = recyclingInterval; // Commit the changes to the server serverManager.CommitChanges(); Console.WriteLine($"Recycling interval for application pool '{appPoolName}' has been set to {recyclingInterval.TotalHours} hours."); } else { Console.WriteLine($"Application pool '{appPoolName}' not found."); } } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } Console.ReadLine(); } }Tuhin PaulRank #7 · 71.9K reputationPosted Mar 11, 2024, 6:56 AM EDT
In IIS, the recycling settings for an application pool, including the recycling interval, can be configured either through the IIS Manager GUI or by modifying the applicationHost.config file directly. you can set the recycling interval to 29 hours using the applicationHost.config file:
In this configuration:
The
section specifies the settings for recycling the worker process. Within, theelement sets the recycling interval to 29 hours using theelement with a value of "29:00:00", where "hh:mm:ss" represents hours, minutes, and seconds.