IIS Application Pool Settings - Idle Timeout and Recycling Print

  • 0

Understanding IIS Application Pool Settings

Application pool settings control how your ASP.NET application runs on the server. Understanding these settings helps troubleshoot stability and performance issues.

What is Application Pool Recycling?

Application pool recycling restarts your application periodically to:

  • Free up memory from potential leaks
  • Apply configuration changes
  • Maintain application stability

Default Settings on Shared Hosting:

Setting Default Value Description
Idle Timeout 20 minutes App stops after 20 minutes of no requests
Regular Time Interval 1740 minutes (29 hours) Periodic recycling schedule
Start Mode OnDemand Starts when first request arrives

Common Issues and Symptoms

Slow First Request (Cold Start)

If your site is slow on the first request after being idle:

  • This is normal behavior due to idle timeout
  • The application needs to restart and warm up
  • Subsequent requests will be fast

Application Restarts Unexpectedly

Your application may restart due to:

  • Scheduled recycling (normal)
  • Memory limit exceeded
  • File changes in the application directory
  • web.config modifications

Solutions for Common Issues

1. Reduce Cold Start Impact

For ASP.NET Core applications, optimize startup:

// Program.cs - Minimize startup work
var builder = WebApplication.CreateBuilder(args);

// Use lazy loading for non-critical services
builder.Services.AddScoped<IHeavyService>(sp =>
    new Lazy<HeavyService>(() => new HeavyService()).Value);

// Cache frequently used data at startup
builder.Services.AddMemoryCache();

2. Keep Application Warm (External Approach)

Use external monitoring services to ping your site periodically:

  • UptimeRobot - Free tier available
  • Pingdom - Professional monitoring
  • Azure Application Insights - If using Azure services

3. Implement Health Check Endpoint

// Add a lightweight health endpoint
app.MapGet("/health", () => Results.Ok("Healthy"));

// External service pings /health every 5-10 minutes

Requesting Application Pool Changes

On shared hosting, application pool settings are managed by the hosting provider. To request changes:

  1. Open a support ticket
  2. Specify which setting you need changed
  3. Explain the business reason
  4. Note: Some settings may not be adjustable on shared plans

Settings That May Be Adjustable:

  • Idle timeout (may be extended)
  • Recycling schedule

Settings Typically Fixed on Shared Hosting:

  • Memory limits
  • CPU limits
  • .NET CLR version (determined by your application)

Blazor Server Specific Considerations

Blazor Server apps maintain persistent SignalR connections. When the app pool recycles:

  • All active user sessions disconnect
  • Users see a "reconnecting" message
  • Circuit state is lost

Mitigation for Blazor Server:

// Configure longer circuit timeout
builder.Services.AddServerSideBlazor()
    .AddCircuitOptions(options =>
    {
        options.DisconnectedCircuitRetentionPeriod = TimeSpan.FromMinutes(10);
        options.DisconnectedCircuitMaxRetained = 100;
    });

When to Contact Support

  • Frequent unexpected application restarts
  • Need to adjust idle timeout for business requirements
  • Experiencing memory-related crashes
  • Application pool stops and won't restart

Was this answer helpful?

« Back