InfluxDB on hassio cpu usage

Dear all,
I have a Raspberry Pi 3 b+ with hassio running, all works perfectly except the cpu load. Is too high, and sometime NodeRed lost the connection with hassio and automation stop working for some seconds.
I think the problem is InfluxDB, you can see a top comand in the attached video.


Here are the InfluxDB settings:
{
  "auth": true,
  "reporting": true,
  "ssl": true,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "envvars": [
    {
      "name": "INFLUXDB_MONITOR_STORE_ENABLED",
      "value": "false"
    }
  ]
}

I think this is good. How can I reduce the cpu load? Have you any idea??

Nobady have this problem? :thinking:

PLEASE HELP ME GUYS :hugs:

Also the python3 process is very cpu expensive…
Cattura

Not sure if still relevant, but posting it here should somebody search for it.

Analysis
I also had issues with very high CPU load a hassio install on a Raspberry PI. I found out this was caused by Influx through issuing the following command (using the SSH addon):

docker stats

This resulted in the following:

It clearly shows influx is the culprit, using most of the CPU and memory resources.

Solution
After a suggestion on the forum and some more googling I found an influx issue suggesting to change influx’s configuration to:

[monitor]
   store-enabled = false

In a default hassio + influx install you can find can do this as follows:

  1. Log into the influxdb addon docker image via SSH (using the aforementioned addon):
docker exec -it [container id] /bin/bash
  1. Go to the directory containing the influxdb configuration file in:
cd /etc/influxdb/
  1. Install a file editor (as there seems to be none installed):
apt-get update
apt-get install joe
  1. Edit the configuration file by appending the above configuration to it:
joe influxdb.conf
  1. Save the configuration file by pressing Ctrl KX (if using joe)

  2. Exit the influxdb container

  3. Restart influx:

docker restart [container id]

In my case everything went back to normal: memory dropped by about 20 percentage points and CPU to 1-2% on average.

2 Likes

Wow, thanks @laurensvp. That totally solved my Influx CPU usage problem! :slight_smile:

I’ve tried this but it’s hard to tell if it’s actually having any affect. The change to influxdb.conf doesn’t appear to be permanent.

Is there a way to permanently modify the default influxdb.conf to persist through restarts?

changing the config file inside the container will not be permanent.
You can change the configuration of InfluxDB through environment variables which you can set using HA supervisor.

envvars:
  - name: INFLUXDB_MONITOR_STORE_ENABLED
    value: 'false'

https://docs.influxdata.com/influxdb/v1.7/administration/config/#monitoring-settings

1 Like

Tried the above change (store-enabled = false) and restarted the container, but it did not change the load on the influxdb container, it is still extremely high!

Any other ideas?

Seem to have found the culprit!

Removed the glances integration, and load fell off a cliff! It is now running at less than 10% of earlier load with very brief spikes up to half of previous load!

Re-added glances, and load stays low!

For me changing to 64bit solve the problem.

2 Likes

Necroed an aging thread, but I think for a good reason.

I had the same issue of high influxdb cpu usage, running current hassos with the influxdb addon. I tried

envvars:
  - name: INFLUXDB_MONITOR_STORE_ENABLED
    value: 'false'

…which did not work for me. Note that I had “restart on reboot” and “watchdog” enabled. What fixed it for me, was simply shutting down the influxdb addon, unselecting watchdog, and rebooting the host. After the reboot, cpu usage is back to normal. Note that I think it was the watchdog setting, as the high cpu use persisted after previous reboots.

Hope this helps someone some day.

Seems I may have lied in my post above… today about 2days later, the high CPU usage returned. A lot of what I have read seems to relate to a 32bit vs 64bit problem, but not sure how to solve that with hassos?

Create a full blackup. Copy it off the system. Install 64bit HA OS. Restore backup.

1 Like

Unfortunately for me, I use esphome. Is there another way, other than turning off influxdb until esphome is fixed?

You don’t have to use the ESPHome addon.

So would this be as simple as pip3 install esphome in an ssh session to my pi4 running hassos… or are you implying I need to have HA in a docker with raspbian? I was hoping for a simple fix… ha os has served me well for some time now and not wanting to switch if at all possible.

I’m saying you don’t have to run the ESPHome application on the same server as home assistant.

OK, this may be the route I go, since I have a NAS where I can put influxdb in docker. I already found a tutorial that describes doing this for HA. This is what I’m thinking of trying:

Before proceeding down that rabbit hole, I have to ask… 32bit HAOS+inlfuxdb addon… won’t have the same problem of high cpu use if the db is moved to my NAS?

I am just worried that influxdb may still try to do whatever operation on the db that is making it ill, even if it is on another system.