Skip to content

Conversation

@dyxyl
Copy link
Contributor

@dyxyl dyxyl commented Oct 13, 2025

As found in #3045 and #4940, some versions of Docker/containerd set the "nofiles" limit very high, which causes beam.smp to use > 2 GB of memory. In particular, this happens in the current Debian stable (13/Trixie).

I've checked that this reduces the memory size in the default docker install, but not the Apache or Traefik installs.

…on Debian 13) by limiting the number of open file descriptors (ulimits nofile) in the example docker-compose.yml files
@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit 9f19d9d
🔍 Latest deploy log https://app.netlify.com/projects/teslamate/deploys/6902149e7feea900095396b1
😎 Deploy Preview https://deploy-preview-4999--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@JakobLichterfeld JakobLichterfeld changed the title Avoid memory bloat in some versions of Docker/containerd (e.g. on Debian 13) perf: Avoid memory bloat in some versions of Docker/containerd (e.g. on Debian 13) Oct 15, 2025
@JakobLichterfeld
Copy link
Member

Thanks for your contribution.
Generally speaking: configuring the host or docker is not in the scope of TeslaMate. There are a ton of useful docker options, but they would blow up the docker guides.

@JakobLichterfeld JakobLichterfeld added undetermined Not sure if this is considered a real bug kind:documentation Adds or improves documentation labels Oct 15, 2025
@JakobLichterfeld JakobLichterfeld marked this pull request as draft October 15, 2025 11:42
@JakobLichterfeld JakobLichterfeld added the note:discussion Details or approval are up for discussion label Oct 15, 2025
@JakobLichterfeld JakobLichterfeld changed the title perf: Avoid memory bloat in some versions of Docker/containerd (e.g. on Debian 13) docs: Avoid memory bloat in some misconfigured versions of Docker/containerd Hosts (e.g. on Debian 13) Oct 15, 2025
@brianmay
Copy link
Collaborator

I think it might be worth while here considering how many people affected. And we already do document the docker-compose file.

@JakobLichterfeld
Copy link
Member

I tend to agree since the beginning.
From a beginner's perspective, these values seem to appear out of nowhere without any explanation. This does not inspire confidence.

cap_drop:
- all
ulimits:
nofile: 65536
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To explain this to newcomers, a comment would greatly enhance UX.

cap_drop:
- ALL
ulimits:
nofile: 65536
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To explain this to newcomers, a comment would greatly enhance UX.

cap_drop:
- all
ulimits:
nofile: 65536
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To explain this to newcomers, a comment would greatly enhance UX.

@JakobLichterfeld JakobLichterfeld added this to the v2.2.0 milestone Oct 16, 2025
@JakobLichterfeld JakobLichterfeld removed note:discussion Details or approval are up for discussion undetermined Not sure if this is considered a real bug labels Oct 16, 2025
@dyxyl
Copy link
Contributor Author

dyxyl commented Oct 16, 2025

I agree about the cryptic nature of these settings.

Please consider the change I've just made to entrypoint.sh instead, so the docker-compose file changes are not needed.

@swiffer
Copy link
Collaborator

swiffer commented Oct 27, 2025

If the change to the entrypoint alone is good enough i would vote for that.

Lower overall maintenance for us and less complexity exposed to users.

Could you update the pr and remove the other changes?

@JakobLichterfeld
Copy link
Member

JakobLichterfeld commented Oct 27, 2025

If the change to the entrypoint alone is good enough i would vote for that.

I do see it differently. This is hiding a setting which is host specific and even worse make it hard coded and not changeable. In my instance the ulimits is much higher and this change will decrease performance.

So I do see several options:

  • an env variable and default to 65536. Which will decrease performance for some users
  • using docker setting, as it is most likely caused by misconfigured docker hosts (and add proper comment). This has the drawback of more maintenance for us and more complexity exposed to users.
  • do not change anything, as it is not TeslaMate related

@swiffer
Copy link
Collaborator

swiffer commented Oct 27, 2025

is that really affecting performance?

  • i read it as "maximum number of simultanously open ports" - and ERL_MAX_PORTS 65536 sounds a lot.

@JakobLichterfeld
Copy link
Member

JakobLichterfeld commented Oct 27, 2025

To add: I strongly vote against using a deprecated env variable:

"Previously the environment variable ERL_MAX_PORTS was used for setting the maximum number of simultaneously existing ports. This environment variable is deprecated, and scheduled for removal in OTP-R17, but can still be used."

source: https://erlang.org/documentation/doc-7.2/erts-7.2/doc/html/erl.html

@swiffer
Copy link
Collaborator

swiffer commented Oct 27, 2025

To add: I strongly vote against using a deprecated env variable:

"Previously the environment variable ERL_MAX_PORTS was used for setting the maximum number of simultaneously existing ports. This environment variable is deprecated, and scheduled for removal in OTP-R17, but can still be used."

source: https://erlang.org/documentation/doc-7.2/erts-7.2/doc/html/erl.html

fully agree, wasn't aware. in that case also voting for nothing or adding it to the docs.

@dyxyl
Copy link
Contributor Author

dyxyl commented Oct 28, 2025

Ah, I didn't realize the env var was deprecated. I've just pushed a change to set the ulimit directly. I don't see how this will decrease performance for anyone (assuming no one has thousands of cars connected to the same instance).

@dyxyl
Copy link
Contributor Author

dyxyl commented Oct 29, 2025

I've refined entrypoint.sh again with a configuration variable and also to avoid an error if the system's limit is smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:documentation Adds or improves documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants