Forum Discussion

ecthomas's avatar
ecthomas
Copper Contributor
Sep 12, 2025

Mysterious Nightly CPU Spikes on App Service Plans (22:00-10:00) Despite Low Traffic

For several months now, all of our Azure App Service Plans have been experiencing consistent CPU spikes during off-peak hours, specifically from approximately 22:00 PM to 10:00 AM.

This pattern is particularly puzzling because:

  • This timeframe corresponds to our lowest traffic and activity periods
  • We've conducted thorough investigations but haven't identified the root cause
  • No scheduled timer functions or planned jobs are running during these hours that could explain the spikes

What we've already checked:

  • Application logs and metrics
  • Scheduled functions and background jobs
  • Traffic patterns and user activity

Has anyone encountered similar behavior?

What could be causing these nightly CPU spikes on otherwise idle App Service Plans?

 

 

2 Replies

  • 1. Split Metrics by Instance

    Start by analyzing CPU usage per instance in Azure Monitor. Aggregated metrics can hide anomalies. Use short time windows and instance-level views to pinpoint which VM is spiking.

    2. Enable Auto-Heal

    Configure Auto-Heal in the App Service diagnostics blade. Set rules to trigger on high CPU usage and automatically recycle the app or log a snapshot for deeper analysis.

    3. Inspect App Pool Recycling

    Check if the App Service Plan is recycling application pools during night hours. This is a common default behavior. Review registry settings like:

    • /Configuration/VssHealthAgent/AppPoolRecycling/FromHour
    • /Configuration/VssHealthAgent/AppPoolRecycling/ToHour
    • /MinimumUptimeInHours

    Adjust these if needed to reduce impact.

    4. Use Process Explorer and Minidump

    Use the Kudu diagnostics suite to inspect running processes during the spike window. The Process Explorer and Minidump API can help identify unexpected background activity.

    5. Review Platform-Level Activity

    Azure may perform internal maintenance, diagnostics, or load balancing during off-peak hours. These operations can cause CPU spikes even if your apps are idle. While not always visible, contacting Azure support with logs and screenshots can help confirm this.

    6. Check for Load Balancer Anomalies

    If using scaled-out App Service Plans, uneven CPU distribution across instances may occur due to load balancer behavior. Consider scaling in or rebalancing instances.

    Preventive Measures

    • Use Managed Identity for secure access and avoid background tasks running unintentionally.
    • Apply Network Security Groups (NSGs) to restrict traffic during off-peak hours.
    • Enable Application Insights to track anomalies and correlate them with platform events.
  • Please try this

     

    1. Enable App Service Diagnostics
    Go to App Service > Diagnose and Solve Problems > Availability & Performance > High CPU Analysis. This tool pinpoints top resource-consuming requests and threads.

    2. Use Azure Monitor CLI
    Run:

    az monitor metrics list \
      --resource /subscriptions/<subid>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<AppName> \
      --metric "CpuPercentage" --interval PT1M

     

    This gives minute-by-minute CPU data to correlate with other logs.

    3. Profile with Application Insights
    Turn on the Profiler to capture snapshots during the spike window. Flame charts can reveal inefficient code paths or unexpected calls.

    4. Check for External Traffic
    Use Network Watcher or App Gateway logs to detect unexpected inbound traffic.

Resources