Skip to content

~20% CPU without ANY flow #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
karl007 opened this issue May 30, 2025 · 2 comments
Open

~20% CPU without ANY flow #1809

karl007 opened this issue May 30, 2025 · 2 comments

Comments

@karl007
Copy link

karl007 commented May 30, 2025

Describe the bug

I recognized (months ago) that my server use much more resources than normal. Today I'm able to debug it complete down to this NR Plugin.

Without any Flow or Node, NR needs from ~0% without this plugin to 15-30% of my servers CPU (not a Pi, a real 8-core server).

To Reproduce

  1. start an empty (no config files) docker container with latest(4.0.9) NR
  2. add this Plugin in NodeRed (node-red-contrib-home-assistant-websocket 0.75)
  3. create a HA node (any - does not matter)
  4. klick + to add ConfigNode
  5. set URL and Token to a HA instance
  6. check CPU and click save

Expected behavior

Don't require CPU without any node/action to do.

Screenshots

No response

Example Flow

Environment Information

Version: 0.75.0

Home Assistant version: 2025.5.3
Companion version: 4.1.2

Node-RED version: 4.0.9
Docker: yes
Add-on: no

Node.js version: v20.19.0 x64 linux
OS: Linux 6.1.64-Unraid x64

HA as DockerContainer, but same issue as HA addon in HA SUpervisor installation

Additional context

NR Log with level trace from saving the HA settings where the CPU rise:

30 May 19:31:15 - [info] Started flows
30 May 19:31:15 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"6739ca3fcb07002dbc384a2cb397926564874e2928926a260e9868656b097af9"},"retain":true}
30 May 19:31:15 - [info] [server:Home Assistant] Connecting to http://homeassistant:8123
30 May 19:31:15 - [info] [server:Home Assistant] Connected to http://homeassistant:8123
30 May 19:31:15 - [debug] [server:Home Assistant] States Loaded
30 May 19:31:15 - [debug] [server:Home Assistant] Services Loaded
30 May 19:31:15 - [debug] [server:Home Assistant] Integration: loaded
30 May 19:31:15 - [debug] [server:Home Assistant] HA State: running
30 May 19:31:15 - [debug] [server:Home Assistant] Registries Loaded
30 May 19:31:27 - [metric] {"level":99,"event":"runtime.memory.rss","value":170041344,"timestamp":1748626287503}
30 May 19:31:27 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":105906176,"timestamp":1748626287503}
30 May 19:31:27 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":70870328,"timestamp":1748626287503}
30 May 19:31:42 - [metric] {"level":99,"event":"runtime.memory.rss","value":172916736,"timestamp":1748626302504}
30 May 19:31:42 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":108167168,"timestamp":1748626302504}
30 May 19:31:42 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":68599552,"timestamp":1748626302504}
[...]
@zachowj
Copy link
Owner

zachowj commented May 31, 2025

When the Home Assistant server configuration is deployed, the integration establishes a persistent WebSocket connection to Home Assistant. At that point, several event listeners are registered to monitor things like state_changed events, and updates to the registry (devices, entities, areas, etc.).

This happens even if you don’t have any nodes in your flow—because the connection setup is part of the server configuration itself, not individual nodes. These listeners are necessary to provide real-time updates and autocomplete features in the editor, and they will consume some CPU depending on the number of entities and frequency of events in your Home Assistant instance.

@karl007
Copy link
Author

karl007 commented May 31, 2025

Yes, but NodeRed requires more CPU % than the whole Hassio VM - this is not really in relation to the work the both do. :(

If the Problems are the websockets, maybe mqtt is better for the realtime events?

Or can this be reduced to a list of only some entities to listen to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants