1

I have been migrating a lot of services to Azure Linux, because I have the assumption Linux is more lightweight. Now I noticed almost all these microservices jumped from around 50mb to 300mb. A lot of them don't use a lot of caching.

Is that normal? Is this like a hefty price for the .NET runtime or something that is included and might be shared on the infrastructure on Windows? Is this a static penalty or does the memory scale worse on Linux (not sure how that should work).

Note that I was running on plain Azure Web Apps - not in Docker. Can this be Docker related?

To answer questions in the comments:

  • running C# .NET Core (ASP.NET Core MVC)
  • they are just Azure Web Apps
  • these apps do VERY little
  • no Mono
  • just recompiled and published to Azure Linux instead of Azure Windows Web App

Basically everything exact the same except that I used Visual Studio to publish to a Linux Web App instead of a Windows-based Web App. I can run them side by side by just republishing them to a different Web App and will see a memory difference of about +200 mb using Process.GetCurrentProcess().PrivateMemorySize64.

Update I just uploaded an almost empty ASP.NET Project:

public class Startup
{
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapGet("/", async context =>
            {
                double size = Process.GetCurrentProcess().PrivateMemorySize64;

                string size_str = Math.Round( size/ (1024*1024) ) + "mb";

                await context.Response.WriteAsync( size_str );
            });
        });
    }
}
  • Vanilla Windows 64bit Azure Web app: about 53 mb
  • Vanilla Linux (64bit?) Azure Web app (docker based as far as I understand): 165 mb
Dirk Boer
  • 8,522
  • 13
  • 63
  • 111
  • 1
    `they are just Web Apps` StackOverflow is just a web app. GMail is just a web app. We can't know what your application does, or even how you measure memory usage. Linux and Windows are *very* different and memory management is anything but simple. That are a *lot* of different page pools, caches, shared pages etc. Checking `PrivateMemorySize64` isn't helpful across OSs. Windows may be able to share more RAM pages between applications. What do the *Azure* monitoring tools show? Have you deployed the same site to Azure Windows and Azure Linux hosts? – Panagiotis Kanavos May 31 '21 at 10:58
  • Corrected - they are just *Azure* Web Apps. They are very simple apps that barely do anything. I'm nowhere hinting that memory management is simple. I'm just wondering if this is to be expected or not because of Docker or .NET on Linux or the integration of Azure on Linux or that I have to look further into application code. – Dirk Boer May 31 '21 at 11:35
  • Well one answer could be: "No a memory jump like that is not normal, I should take a hard look at your configuration or packages that you are using". Another one could be: "perfectly normal there is a 200MB memory penalty by using Docker, we see this also at all our own microservices". Another one could be "We have seen this using the default Azure Web App Docker containers, but not if we use the Azure Kubernetes system (or whatever)". Another one could be "Perfectly normal, the .NET runtime uses 200MB and you can't get around this except on Windows" ‍♂️ – Dirk Boer May 31 '21 at 16:39
  • 1
    Perhaps a better and more specific question, then : [What is the runtime performance cost of a Docker container?](https://stackoverflow.com/q/21889053/327083) This focuses on performance rather than memory, but perhaps a better question here would be "What is the memory overhead of a Docker container"?. Anyway, +1 because the question is already much better. – J... May 31 '21 at 16:58
  • Thanks for your understanding! I'll take a deeper look at the question you refer! – Dirk Boer May 31 '21 at 23:32

0 Answers0