Increasing CPU load over time (bcs of short term statistics db?)

Hi there,

I have a supervised install on Debian.
The CPU load spikes every 5 minutes of the hour. And during the day those spikes increase. After a restart of HA, the spikes are gone, but will return again during the day.

I see nothing in the logs with which I can work on. I’ve checked all of the events, nothing there either.


CPU2

I thought it might me a dbase filling up, but why does it go down after a restart?

I’m a bit at a loss regarding where to start looking. Anyone any ideas?

Thanks!

It looks like mariadb is the culprit. Every 5 mins on the dot it spikes the cpu in the debian sysmon.

I’ll keep digging to see why it causes a gradual increase when time goes by.

The cpu usage of the maria db add on in supervisor stays flat… curious…:thinking:

Got zoneminder or anything recording cctv on that machine? That’s a clear night/day load difference.

For further diagnosis, ‘htop’ is the tool I use to clearly see what’s using load at any given time. You’ve identified mariadb, so using a mysql client, connect to it and run ‘SHOW PROCESSLIST;’ to see what queries and sql users are creating the load.

Hi,

Thanks for your reply.

The night/day diff is caused by me restarting HA at 6:30 ish. After which the CPU load drops.
I havent restarted HA for 24 hrs and the load keeps increasing.

With phpmadmin I have discovered that HA has “statistic runs” every 5 mins of the hour.
The increase in CPU matches the creation of the statistics in HA on the second.

But how comes the CPU load increases over time? What makes the statistics more difficult to process or less difficult after a restart?

More digging…

I have removed all statistic sensors. Let’s see what happens.

Cleared the statistics short term DB. It was 24 mb.

It starts to fill up again, logically, but the CPU load hardly moves.

My recorder keep time is 2 days. I’ll check if the CPU load increases after two days.

Hi there,

My short term statistic db (mariadb) seems to load up my cpu. Increasing over time even.

See also here:

https://community.home-assistant.io/t/increasing-cpu-load-during-the-day/450783/5?

Does anyone recognizes this kind of behaviour?

I’ll check if the cpu load increase will stop or eventually will crash my system.

Any tips would be much appreciated.

Thanks!

I don’t understand.

The increase in CPU load seemed to level off after 48 hrs.

However after a purge/repack, the load doubled. go figure.

The purge was set as an automation with the service. I now have it set to do via autopurge and auto repack in the config. Let’s see if that makes any difference.

I removed MariaDB and switched back to the default HA db.

No more rise in CPU load.

I would be delighted if someone could help me out why the load was increasing because of MariaDB.

CPU 4

This is a shot in the dark, but Docker uses the json-file logging driver by default, which does not perform log-rotation and logs grow forever until a container restarts. Maybe it is the MariaDB container log bogging down? Info on Docker logging here - Configure logging drivers.

The docker recommendation is to use “local” logging, but since I don’t need to see container logs I have set logging to “none”. Home assistant still logs to //config/home-assistant.log, which is the log you see inside home assistant anyway. I don’t know how much control you have over this in Supervisor (I used to use Supervisor but have gone back to Container).

Hi Jambalaya,

This does exactly describe the symtoms I had. I’ve not taken the effort to further investigate. Now with a the local db, the performance is stable. But thanks anyway.