Hi guys,
Is there any Docker image I can use to build the smallest Erlang VM in term of memory usage and disk space?
Currently, I’m shipping my containers based on Ubuntu 22.04 LTS. They are pretty large and consume +200MB of RAM during startup (not even under load).
My task in the next weeks is to deploy more containers, and I can’t afford wasting memory like that.
Disclaimer: newbie here. I know only basics Docker.
Many thanks
If I just start an Erlang shell it uses about 37 MB of memory (as shown by erlang:memory(total)
) and then another 13 MB in caches and pre-allocated memory (docker stats
shows 50 MB of memory usage). To get that value down a bit I can start erl like this:
docker run -it erlang:26 erl +S 1 +SDio 1 +P 1024 +Q 1024 -mode minimal
That brings the memory usage down to 11 MB with 9 MB in caches etc, but it puts some constraints on the system that you might not want.
To decrease the amount of diskspace used, you should go for a multistage docker build where you only copy over your release. Like what is done here: GitHub - erlang/docker-erlang-example: HowTo Erlang in Docker and specifically in this Dockerfile .
4 Likes
@garazdawi thanks a lot. Let me give it go
@garazdawi Is this still the case, or has the problem already been solved?
opened 02:06PM - 24 May 23 UTC
closed 06:07AM - 25 Aug 23 UTC
team:VM
bug
**Describe the bug**
Application down few seconds after the run release in AWS … eks
**To Reproduce**
Unfortunately i have no idea how to reproduce.
**Affected versions**
26.0
**Additional context**
AWS EKS
erlang 26.0
alpine 3.18.0
Application logs
```
hend=0x00007f4f6f34c7f0
stop=0x00007f4f6f34c670
htop=0x00007f4f6f34c678
heap=0x00007f4f6f349600
beam/erl_gc.c, line 735: <0.3141.0>: Overrun stack and heap
```
I came across this after reading Elixir question:
Using Alpine and musl instead of GNU libc affect performance?
@garazdawi -mode minimal
seems undocumented. Is there any available information on what it does?
2 Likes
If you read the last comment of that issue you can see that it had nothing to do with using musl and yes it has been fixed.
1 Like
Using -mode minimal
disables some kernel services mostly related to distribution and timers. I thought it was documented by apparently not. It has minimal effect on memory usage, but it does shave a few KBs off as a couple of processes are not started.
1 Like