Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
How to fix webapp container memory issue ?
I deployed frontend and backend of my application on azure webapp, application is working but some times during output generation time its throwing network error, when i checked logs its showing me out of memory issue spike but , in webapp container i am not able to see any issue related to memory or CPU. but application is continuously throwing network error, sometimes its working fine.
Azure App Service
-
Mahender Singh • 20 Reputation points
2025-11-10T07:07:05.6833333+00:00 Hi Azure community , Please give your feedback it will be great help for me. adding screenshot for your reference as well.
Now i increase the webapp pricing tier as well , here i can see azure offer me 3.75Gi memory but even i am not using my deployed application before that container itself consuming 1.8Gi out of 3.75Gi, so how we can troubleshoot, which service of webapp is eating the memory, even my application is not getting sufficient memory. Container memory status .jpg
-
Shree Hima Bindu Maganti • 7,590 Reputation points • Microsoft External Staff • Moderator
2025-11-10T07:22:28.6766667+00:00 Hi @Mahender Singh
This issue occurs because the Azure App Service on Linux container consumes a large portion of memory even when idle, due to background platform services, container runtime processes, and diagnostic agents running inside the sandbox. As a result, your application may get less usable memory than the plan’s total (e.g., 3.75 GiB), causing intermittent “network errors” or “out of memory” exceptions during high-load operations. To troubleshoot, first check the App Service diagnostics under Diagnose and solve problems Availability and Performance Memory Usage.Then, review App Service metrics like Memory Working Set and Memory Limit (link) to identify spikes. You can also use Kudu SSH to runtoporps aux --sort=-rssand identify memory-hungry processes. If the issue persists, capture a memory dump using App Service diagnostics tools to detect leaks in your code. Finally, consider scaling up to a higher tier or enabling Auto-Heal rules to recycle the app when memory usage is high
https://learn.microsoft.com/en-us/azure/app-service/manage-scale-up
https://learn.microsoft.com/en-us/azure/app-service/overview-diagnostics?utm_source=chatgpt.com
Let me know if you have any further assistances needed. -
Shree Hima Bindu Maganti • 7,590 Reputation points • Microsoft External Staff • Moderator
2025-11-10T08:47:15.25+00:00 Hi @Mahender Singh
Thank you for providing the details and screenshot.According to the diagnostics, your Web App is showing high memory and CPU usage, which may result in occasional network errors and reduced performance. This appears to be caused by memory consumption within the container and limited swap space on the host. Even when the app is idle, some memory remains reserved for the App Service runtime and container overhead.
To address this, please check the process list through App Service Diagnostics Memory Usage View processes consuming high memory. Look for processes, including your application or background tasks, that are using a lot of memory. If you find memory leaks or large objects, try optimizing your code or dependencies. You can also enable Auto-Scale to manage workload spikes, and if your app often reaches its memory limit, consider upgrading to a higher App Service Plan tier.
https://learn.microsoft.com/en-us/azure/app-service/manage-scale-up
https://learn.microsoft.com/en-us/azure/app-service/overview-diagnosticsLet me know if you have any further assistances needed.
-
Mahender Singh • 20 Reputation points
2025-11-12T07:29:44.5533333+00:00 Hi @SHREE HIMA BINDU MAGANTI as we discussed yesterday could you please share me updates on it please.
-
Shree Hima Bindu Maganti • 7,590 Reputation points • Microsoft External Staff • Moderator
2025-11-12T17:35:03.1633333+00:00 Hi @Mahender Singh
Could you please check now and confirm whether the issue still appears the same?
Thank you for sharing the detailed logs and explanation. Based on the log entries, it appears that your Azure Web App is frequently restarting the Gunicorn master and worker processes. Entries like "Handling signal: term," "Worker exiting," and "Shutting down: Master" suggest that the App Service platform is recycling the web app container.This recycling may be triggered by memory pressure, health probe timeouts, or short spikes in resource usage within the container. Even if Azure metrics do not show sustained high memory or CPU usage, brief memory spikes or blocked worker threads can prompt App Service to restart the process for stability. This can cause ongoing requests, particularly resource-intensive ones, to fail with network or invalid task errors, which explains the intermittent problem.
Regarding the increase in idle memory usage after scaling from Base 1 to Base 2, this is expected. Upgrading the pricing tier allocates more memory, and the runtime (Python/Gunicorn/OS) adjusts its caching and garbage collection buffers accordingly. As a result, the app may appear to use more memory while idle, but it is actually utilizing the available resources more efficiently.
For further troubleshooting, you can:
Enable Application Insights Live Metrics Stream to monitor memory and worker activity in real time.
Use App Service Diagnostics Availability and Performance Memory Analysis to capture memory dumps during issues.
Check the Container Crash Count and Memory Working Set metrics in Azure Monitor to determine if frequent recycling is occurring.
https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#out-of-memory-errorshttps://learn.microsoft.com/en-us/azure/app-service/monitor-instances-health-check?tabs=dotnet
https://www.geeksforgeeks.org/devops/identify-and-diagnose-apps-with-high-memory-in-microsoft-azure/
https://github.com/MicrosoftDocs/SupportArticles-docs/blob/main/support/developer/webapps/iis/site-behavior-performance/high-memory-consumption-issues-overview.md
Let me know if you have any further assistances.
Sign in to comment