Azure / Azure/Azure-Functions

3 times higher memory usage of docker image when using azure functions host vs. custom host

Open
#1,810 4 comments 0 reactions 0 assignees View on GitHub
.Net 5.0 lang-F#
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

I have converted a .net core 3.1 Azure Functions app to a self-hosted .Net 5.0 asp.net core app (using Kestrel and Webjobs SDK) and I am observing 3 times difference in memory footprint (**Azure Functions Host: 180+ MiB, Custom Host: 60 Mib**) in docker, running locally on my machine.

Why is the Azure Functions Host consuming 3x the memory? I have been always wondering why my relatively simple microservice pods are consuming 200-300 Mb of memory ...

Docker Image for .net Core 3.1 Azure Functions app:
```
FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY ./publish /home/site/wwwroot
```

Docker Images for .net 5.0 Custom Host app:
```
FROM mcr.microsoft.com/dotnet/aspnet:5.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY ./publish /home/site/wwwroot
WORKDIR /home/site/wwwroot
ENTRYPOINT ["dotnet", "CustomNamespace.CustomProject.dll"]
```

Note: Language is F#, and the custom host is encapsulated in an additional Program.fs file I added to my existing Azure Function App project, containing Host.CreateDefaultBuilder, builder.ConfigureServices, builder.ConfigureLogging, builder.ConfigureWebJobs, builder.ConfigureWebHostDefaults and similar ... I added also

`Exe`

to the project file, removed

``

and changed

`net5.0`

...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.