CPU and memory spikes in azure app service plan every 8 hours

Jeroen Vrijkorte 26 Reputation points
2022-01-12T09:18:15.327+00:00

Hello,

My Azure App Service Plan has unexplained memory and cpu spikes every 8 hours. There are several apps on the app service plan, but only one production application that has regular usage. The production app has fairly low utilization, and only during business hours. The memory and cpu spikes appear completely unrelated to the usage of the app.

I have looked at the cpu and private bytes charts of each individual app, but none of the apps show this periodic pattern, or high cpu or memory usage at all.

The spikes do not currently cause any issues, but they could in the future, and I would like to understand what is going on. Is this normal? What could be causing these spikes? How to diagnose?

List item

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,688 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Robert Fitch 5 Reputation points
    2023-02-01T17:28:07.08+00:00

    Hi @Jeroen Vrijkorte ,

    I have exactly the same spikes, also every 8 hours. I looked at the garbage collection metric of each of the app services in my service plan. Sure enough, one of the services was doing a garbage collection every 8 hours at the time of the spikes. In my case, it is a server which handles an Angular web application.

    I haven't found out what exactly is responsible for triggering the garbage collection, perhaps the Angular system itself. Anyway, it is clear that garbage collection is necessary at intervals and that it is a CPU-intensive operation which temporarily reserves alot of memory. Garbage collection always runs at low priority, so it should not affect the performance of your application.

    Regards, Bob

    1 person found this answer helpful.

  2. Ryan Hill 25,141 Reputation points Microsoft Employee
    2022-01-12T20:10:02.367+00:00

    Hi @Jeroen Vrijkorte ,

    It's difficult to ascertain a root cause based on the graph you've shared. Furthermore, it's difficult to see how long the spikes last at the 8-hour interval. Troubleshoot performance degradation is great place to start to setup application insights and monitoring your application.

    Since it occurs every 8-hours, here are some areas I would focus on. Are there any requests that hit your app at that time? In looking at the graph, your app is doing some sort of process that's causing the memory allocation. If your app isn't getting hit with requests, then the next place I would look is any background processing threads. If the issue is GC related, then that should show on any performance counter graphs. If your application is .NET based, you profile it to gain better understanding what's being allocated by what callers.

    ---
    EDIT: 1/28/2022
    Just to follow up with your offline discussion. You had the aggregation of your metrics set on max and by switching it to average, you felt more comfortable with what you were seeing. Should something appear out of place, the referenced links will guide you on how to determine the root cause.


  3. Jinssi 0 Reputation points Microsoft Employee
    2023-11-14T12:55:43.3533333+00:00

    This looks like maintenance tasks on the underlying Virtual Machine, probably the polling Defender does for updates. It's noticeable on smaller single core VM's and can affect your app for the duration of the polling/updating. Nothing you can (or even should) disable nor worry about. You can confirm this with support by opening a ticket.

    0 comments No comments