dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.27k stars 4.73k forks source link

High netcore memory usage compared to windows (From an VS Template starter app) #78962

Open stusklinar opened 1 year ago

stusklinar commented 1 year ago

Description

We've noticed issues with Azure App Services (linux) using more memory than we'd expect for linux apps vs Windows

To test this and take everything out of the equation - I used Visual Studio to create a new Web Api (Weather Forecast), and ran it locally using Windows, deployed it to a Linux App Service and ran it via WSL.

The Windows run ran as expected, using around 20mb to run the app, however, out of the box with no adjustments, the Linux version needs around 170mb to just exist. All good and well, until we can only fit a few app within an app service on Azure.

This makes the move to Linux not viable for us, and perhaps others as the machines required to run simple APIs is too much compared to Windows.

Configuration

Standard out of the box .net 6 or 7

Data

HTOP Before running the app

image

HTOP After starting (In release mode)

image

Analysis

Console apps seem to also have this issue, with 8mb (Windows) compared to 100mb (Linux)

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.

Issue Details
### Description We've noticed issues with Azure App Services (linux) using more memory than we'd expect for linux apps vs Windows To test this and take everything out of the equation - I used Visual Studio to create a new Web Api (Weather Forecast), and ran it locally using Windows, deployed it to a Linux App Service and ran it via WSL. The Windows run ran as expected, using around 20mb to run the app, however, out of the box with no adjustments, the Linux version needs around 170mb to just exist. All good and well, until we can only fit a few app within an app service on Azure. This makes the move to Linux not viable for us, and perhaps others as the machines required to run simple APIs is too much compared to Windows. ### Configuration Standard out of the box .net 6 or 7 ### Data HTOP Before running the app image HTOP After starting (In release mode) image ### Analysis Console apps seem to also have this issue, with 8mb (Windows) compared to 100mb (Linux)
Author: stusklinar
Assignees: -
Labels: `tenet-performance`, `area-GC-coreclr`, `untriaged`
Milestone: -
mangod9 commented 1 year ago

Hi @stusklinar, do you observe this behavior with a vanilla .NET app, or is it specific to a particular app? Also are you running in a memory constrained container environment?

stusklinar commented 1 year ago

This is a vanilla app, with no changes, in a normal app service

MattMinke commented 1 year ago

We are seeing this behavior as well in Azure where a App Service with Windows OS uses significantly less memory than an App Service running Linux OS.

image

Others have documented this issue on stack overflow as well.

mangod9 commented 1 year ago

I wonder whether this is just a function of available memory on the running container? Do you observe the same behavior if you force to run with WKS GC?