Why is Influx DB using 50% CPU...it is too much!

You can put the InfluxDB add-on into debug or trace logging and verify your theory that it’s saving more frequently than configured to. Or you can query InfluxDB itself and look at what’s in there to determine if there is more than expected (i.e. OH is storing more than configured).

I’m skeptical that’s the cause of the problem and ultimately you will find the answer to your problem on an InfluxDB forum.

You might consider what media it stores to, and what else competes for that.

If you wanted to discuss rrd4j setup, it’d probably avoid confusion if you started a new thread. Yes, it does compress old data, that is exactly the point of rrd4j.

1 Like

I have commented out everysecond and removed some everychange instructions that were triggering frequently, restarted OpenHab but sadly still high CPU usage, thanks anyways.

What are you storing here, about 150 Items every minute plus any changes? 200 states a minute?

Just some thoughts:

  • Your CPU is at 100%. So the CPU is limiting what ever is causing the load. Meaning there would be even more absolute load if your CPU was faster.
    This does not help, but I wanted to point this out anyway.
  • You disabled everySecond. But everyChange could cause even bigger harm depending on how often the state of your items change.
  • I would take a look at the openhab.logand events.log to see if there is an unusual amount of activity.
  • To isolate the problem you can comment out your items in the persistent file one by one to see if a specific item/line is causing the issue.

Great suggestions, so…

That is my latest configuration, set to every10Seconds or everyMinute

Restarted OH. CPU drops to 2%, nice…
After OH started completely CPU is still on 100% and influx between 14 and 50%. If I observe SSD disk usage it is between 0 and 800 KB/s pulsing every 10s seems normal.

I know I expect a lot of performance from the “rocket in the pocket” device, but if it runs other things with 40% avg. load it should run DB as weal if polished.

I had trouble with rrd4j when displaying short impulses or digital values on graphs, it didn’t seem accurate at all it always created awful graphs, was it misconfigured?.

What DB is a viable alternative, if configured properly, to be able to show accurate graphs and historic data values like InfluxDB?

If another DB is the answer we can discuss here: Best Persistence for Graphing and Impulsed Data

If I can polish Influx DB in any way then great. I see that influx runs through HTTP and Network Adapter is constantly in 6-8 Mbit/s Range. Am I configuring it wrong or it isn’t suitable for the job, my uncle said that they were choosing a DB for some project a decade ago and some DBs were revving CPU for no good reason, some were destroying pulsed and digital data over some time (visible in graphs) like rrd4j, and some they din’t tried, and kept crappy one that is still causing them trouble today :rofl:.

Which solution is possible to have reliable data Like InfluxDB and CPU usage like rrd4j (which I used before with same configuration).

Thanks, Matej

On Linux I would say look at your /var/log/syslog file to see what InfluxDB is doing, but I don’t know where it logs on Windows. If you can find that it might help. InfluxDB does occasionally rearrange its database, but I haven’t seen it continually use high CPU. Do you have some continuous queries that are running frequently?

The most frequent being every 10 s with about 60 items in total. But I would expect CPU pulsing every 10s. I am gonna search for DB logs.

Thanks, Matej

Like, uh, graphing ?

I’m asking about the continuous queries that you can set inside InfluxDB, typically in order to reduce resolution such as taking the average over the last hour and inserting it as a new measurement. But you also make the good point that if something like Grafana is refreshing frequently you’ll see a lot of traffic. All of this should show up in the InfluxDB logs if they can be found…

Aha, you mean averaging queries like this.
image
I have about 10 averageSince querries.

Yes graphing is somewhat tasking but it is unlikely that any web ui would be left open on any of our devices at given time.

InfluxDB has its own continuous queries which is what I meant, but I suspect you are not using them. Yes, the queries you list would use CPU, but enough to cause the high load that you see? Maybe the log file will show something.

My first question would be if you experience any problems. :smiley: It is not necessary a bad thing if the resources you have (CPU, Memory, …) are actually used as long as the system performs it duties. Of course, it’s always nice to have some spare capacity, but that depends on other tasks to run, if any.

On the point of CPU usage of InfluxDB, you mention you see between 14% and 50% usage with the adjusted config. Did you chart the CPU usage with Perfmon to see how it fluctuates from moment to moment, if at all? Task manager is averaging out over a time period.
Also, it is important to see what is actually stored in the database, either with graphing (i.e. Grafana) or CLI queries of the measurements.

I would definitely say there is a problem.

I had openHAB, influxDB and Grafana running on a single RaspberryPi 3 two years ago.
I did not use every10seconds and the system was a little slow, but I think any computer capable of running Windows should be able to do this job without heavy CPU usage.

I found out that by default InfluxDB desn’t make log file.

The computer is a bit slow when I connect RemoteDesktop and it can’t open programs fast enough.

Some influxdb diagnostics data from SHOW DIAGNOSTICS command

> SHOW DIAGNOSTICS
name: build
Branch Build Time Commit                                   Version
------ ---------- ------                                   -------
1.7               23bc63d43a8dc05f53afa46e3526ebb5578f3d88 1.7.9

name: config
bind-address   reporting-disabled
------------   ------------------
127.0.0.1:8088 false

name: config-coordinator
log-queries-after max-concurrent-queries max-select-buckets max-select-point max
-select-series query-timeout write-timeout
----------------- ---------------------- ------------------ ---------------- ---
-------------- ------------- -------------
0s                0                      0                  0                0
           0s            10s

name: config-cqs
enabled query-stats-enabled run-interval
------- ------------------- ------------
true    false               1s

name: config-data
cache-max-memory-size cache-snapshot-memory-size cache-snapshot-write-cold-durat
ion compact-full-write-cold-duration dir                                    max-
concurrent-compactions max-index-log-file-size max-series-per-database max-value
s-per-tag series-id-set-cache-size wal-dir                               wal-fsy
nc-delay
--------------------- -------------------------- -------------------------------
--- -------------------------------- ---                                    ----
---------------------- ----------------------- ----------------------- ---------
--------- ------------------------ -------                               -------
--------
1073741824            26214400                   10m0s
4h0m0s                           C:\Users\Matej Streznik\.influxdb\data 0
                   1048576                 1000000                 100000
      100                      C:\Users\Matej Streznik\.influxdb\wal 0s

name: config-httpd
access-log-path bind-address enabled https-enabled max-connection-limit max-row-
limit
--------------- ------------ ------- ------------- -------------------- --------
-----
            :8086        true    false         0                    0

name: config-meta
dir
---
C:\Users\Matej Streznik\.influxdb\meta

name: config-monitor
store-database store-enabled store-interval
-------------- ------------- --------------
_internal      true          10s

name: config-precreator
advance-period check-interval enabled
-------------- -------------- -------
30m0s          10m0s          true

name: config-retention
check-interval enabled
-------------- -------
30m0s          true

name: config-subscriber
enabled http-timeout write-buffer-size write-concurrency
------- ------------ ----------------- -----------------
true    30s          1000              40

name: network
hostname
--------
MatejStreznik

name: runtime
GOARCH GOMAXPROCS GOOS    version
------ ---------- ----    -------
amd64  2          windows go1.12.6

name: system
PID  currentTime                  started                      uptime
---  -----------                  -------                      ------
3960 2020-01-25T13:47:37.1251169Z 2020-01-23T12:13:48.3818359Z 49h33m48.743281s
>

Don’t want to annoy anyone with lengthy stats but it might be useful.

command SHOW STATS

    ej Streznik\.influxdb\data\_internal\monitor\20, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\20
cacheCompactionDuration cacheCompactionErr cacheCompactions cacheCompactionsActi
ve tsmFullCompactionDuration tsmFullCompactionErr tsmFullCompactionQueue tsmFull
Compactions tsmFullCompactionsActive tsmLevel1CompactionDuration tsmLevel1Compac
tionErr tsmLevel1CompactionQueue tsmLevel1Compactions tsmLevel1CompactionsActive
 tsmLevel2CompactionDuration tsmLevel2CompactionErr tsmLevel2CompactionQueue tsm
Level2Compactions tsmLevel2CompactionsActive tsmLevel3CompactionDuration tsmLeve
l3CompactionErr tsmLevel3CompactionQueue tsmLevel3Compactions tsmLevel3Compactio
nsActive tsmOptimizeCompactionDuration tsmOptimizeCompactionErr tsmOptimizeCompa
ctionQueue tsmOptimizeCompactions tsmOptimizeCompactionsActive
----------------------- ------------------ ---------------- --------------------
-- ------------------------- -------------------- ---------------------- -------
----------- ------------------------ --------------------------- ---------------
------- ------------------------ -------------------- --------------------------
 --------------------------- ---------------------- ------------------------ ---
----------------- -------------------------- --------------------------- -------
--------------- ------------------------ -------------------- ------------------
-------- ----------------------------- ------------------------ ----------------
---------- ---------------------- ----------------------------
0                       0                  0                0
   0                         0                    0                      0
            0                        0                           0
        0                        0                    0
 0                           0                      0                        0
                  0                          0                           0
                0                        0                    0
         0                             0                        0
           0                      0

name: tsm1_cache
tags: database=_internal, engine=tsm1, id=20, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\20, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\20
WALCompactionTimeMs cacheAgeMs cachedBytes diskBytes memBytes snapshotCount writ
eDropped writeErr writeOk
------------------- ---------- ----------- --------- -------- ------------- ----
-------- -------- -------
0                   0          0           0         0        0             0
         0        0

name: tsm1_filestore
tags: database=_internal, engine=tsm1, id=20, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\20, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\20
diskBytes numFiles
--------- --------
1508535   1

name: tsm1_wal
tags: database=_internal, engine=tsm1, id=20, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\20, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\20
currentSegmentDiskBytes oldSegmentsDiskBytes writeErr writeOk
----------------------- -------------------- -------- -------
0                       0                    0        0

name: shard
tags: database=_internal, engine=tsm1, id=21, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\21, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\21
diskBytes fieldsCreate seriesCreate writeBytes writePointsDropped writePointsErr
 writePointsOk writeReq writeReqErr writeReqOk
--------- ------------ ------------ ---------- ------------------ --------------
 ------------- -------- ----------- ----------
1536582   0            68           0          0                  0
 266679        4233     0           4233

name: tsm1_engine
tags: database=_internal, engine=tsm1, id=21, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\21, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\21
cacheCompactionDuration cacheCompactionErr cacheCompactions cacheCompactionsActi
ve tsmFullCompactionDuration tsmFullCompactionErr tsmFullCompactionQueue tsmFull
Compactions tsmFullCompactionsActive tsmLevel1CompactionDuration tsmLevel1Compac
tionErr tsmLevel1CompactionQueue tsmLevel1Compactions tsmLevel1CompactionsActive
 tsmLevel2CompactionDuration tsmLevel2CompactionErr tsmLevel2CompactionQueue tsm
Level2Compactions tsmLevel2CompactionsActive tsmLevel3CompactionDuration tsmLeve
l3CompactionErr tsmLevel3CompactionQueue tsmLevel3Compactions tsmLevel3Compactio
nsActive tsmOptimizeCompactionDuration tsmOptimizeCompactionErr tsmOptimizeCompa
ctionQueue tsmOptimizeCompactions tsmOptimizeCompactionsActive
----------------------- ------------------ ---------------- --------------------
-- ------------------------- -------------------- ---------------------- -------
----------- ------------------------ --------------------------- ---------------
------- ------------------------ -------------------- --------------------------
 --------------------------- ---------------------- ------------------------ ---
----------------- -------------------------- --------------------------- -------
--------------- ------------------------ -------------------- ------------------
-------- ----------------------------- ------------------------ ----------------
---------- ---------------------- ----------------------------
10508789200             0                  3                0
   3632812500                0                    0                      2
            0                        0                           0
        0                        0                    0
 0                           0                      0                        0
                  0                          0                           0
                0                        0                    0
         0                             0                        0
           0                      0

name: tsm1_cache
tags: database=_internal, engine=tsm1, id=21, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\21, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\21
WALCompactionTimeMs cacheAgeMs cachedBytes diskBytes memBytes snapshotCount writ
eDropped writeErr writeOk
------------------- ---------- ----------- --------- -------- ------------- ----
-------- -------- -------
10465               14404083   63378001    0         0        0             0
         0        6001

name: tsm1_filestore
tags: database=_internal, engine=tsm1, id=21, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\21, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\21
diskBytes numFiles
--------- --------
1536582   1

name: tsm1_wal
tags: database=_internal, engine=tsm1, id=21, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\21, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\21
currentSegmentDiskBytes oldSegmentsDiskBytes writeErr writeOk
----------------------- -------------------- -------- -------
0                       0                    0        4233

name: shard
tags: database=_internal, engine=tsm1, id=22, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\22, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\22
diskBytes fieldsCreate seriesCreate writeBytes writePointsDropped writePointsErr
 writePointsOk writeReq writeReqErr writeReqOk
--------- ------------ ------------ ---------- ------------------ --------------
 ------------- -------- ----------- ----------
1498281   655          68           0          0                  0
 544745        8640     0           8640

name: tsm1_engine
tags: database=_internal, engine=tsm1, id=22, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\22, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\22
cacheCompactionDuration cacheCompactionErr cacheCompactions cacheCompactionsActi
ve tsmFullCompactionDuration tsmFullCompactionErr tsmFullCompactionQueue tsmFull
Compactions tsmFullCompactionsActive tsmLevel1CompactionDuration tsmLevel1Compac
tionErr tsmLevel1CompactionQueue tsmLevel1Compactions tsmLevel1CompactionsActive
 tsmLevel2CompactionDuration tsmLevel2CompactionErr tsmLevel2CompactionQueue tsm
Level2Compactions tsmLevel2CompactionsActive tsmLevel3CompactionDuration tsmLeve
l3CompactionErr tsmLevel3CompactionQueue tsmLevel3Compactions tsmLevel3Compactio
nsActive tsmOptimizeCompactionDuration tsmOptimizeCompactionErr tsmOptimizeCompa
ctionQueue tsmOptimizeCompactions tsmOptimizeCompactionsActive
----------------------- ------------------ ---------------- --------------------
-- ------------------------- -------------------- ---------------------- -------
----------- ------------------------ --------------------------- ---------------
------- ------------------------ -------------------- --------------------------
 --------------------------- ---------------------- ------------------------ ---
----------------- -------------------------- --------------------------- -------
--------------- ------------------------ -------------------- ------------------
-------- ----------------------------- ------------------------ ----------------
---------- ---------------------- ----------------------------
15496093900             0                  4                0
   3813476700                0                    0                      2
            0                        0                           0
        0                        0                    0
 0                           0                      0                        0
                  0                          0                           0
                0                        0                    0
         0                             0                        0
           0                      0

name: tsm1_cache
tags: database=_internal, engine=tsm1, id=22, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\22, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\22
WALCompactionTimeMs cacheAgeMs cachedBytes diskBytes memBytes snapshotCount writ
eDropped writeErr writeOk
------------------- ---------- ----------- --------- -------- ------------- ----
-------- -------- -------
15469               14402875   91285002    0         0        0             0
         0        8640

name: tsm1_filestore
tags: database=_internal, engine=tsm1, id=22, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\22, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\22
diskBytes numFiles
--------- --------
1498281   1

name: tsm1_wal
tags: database=_internal, engine=tsm1, id=22, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\22, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\22
currentSegmentDiskBytes oldSegmentsDiskBytes writeErr writeOk
----------------------- -------------------- -------- -------
0                       0                    0        8640

name: shard
tags: database=_internal, engine=tsm1, id=23, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\23, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\23
diskBytes fieldsCreate seriesCreate writeBytes writePointsDropped writePointsErr
 writePointsOk writeReq writeReqErr writeReqOk
--------- ------------ ------------ ---------- ------------------ --------------
 ------------- -------- ----------- ----------
1939565   655          68           0          0                  0
 316370        5015     0           5015

name: tsm1_engine
tags: database=_internal, engine=tsm1, id=23, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\23, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\23
cacheCompactionDuration cacheCompactionErr cacheCompactions cacheCompactionsActi
ve tsmFullCompactionDuration tsmFullCompactionErr tsmFullCompactionQueue tsmFull
Compactions tsmFullCompactionsActive tsmLevel1CompactionDuration tsmLevel1Compac
tionErr tsmLevel1CompactionQueue tsmLevel1Compactions tsmLevel1CompactionsActive
 tsmLevel2CompactionDuration tsmLevel2CompactionErr tsmLevel2CompactionQueue tsm
Level2Compactions tsmLevel2CompactionsActive tsmLevel3CompactionDuration tsmLeve
l3CompactionErr tsmLevel3CompactionQueue tsmLevel3Compactions tsmLevel3Compactio
nsActive tsmOptimizeCompactionDuration tsmOptimizeCompactionErr tsmOptimizeCompa
ctionQueue tsmOptimizeCompactions tsmOptimizeCompactionsActive
----------------------- ------------------ ---------------- --------------------
-- ------------------------- -------------------- ---------------------- -------
----------- ------------------------ --------------------------- ---------------
------- ------------------------ -------------------- --------------------------
 --------------------------- ---------------------- ------------------------ ---
----------------- -------------------------- --------------------------- -------
--------------- ------------------------ -------------------- ------------------
-------- ----------------------------- ------------------------ ----------------
---------- ---------------------- ----------------------------
3208984400              0                  2                0
   0                         0                    0                      0
            0                        0                           0
        0                        0                    0
 0                           0                      0                        0
                  0                          0                           0
                0                        0                    0
         0                             0                        0
           0                      0

name: tsm1_cache
tags: database=_internal, engine=tsm1, id=23, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\23, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\23
WALCompactionTimeMs cacheAgeMs cachedBytes diskBytes memBytes snapshotCount writ
eDropped writeErr writeOk
------------------- ---------- ----------- --------- -------- ------------- ----
-------- -------- -------
3197                518998     52435508    0         696987   0             0
         0        5015

name: tsm1_filestore
tags: database=_internal, engine=tsm1, id=23, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\23, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\23
diskBytes numFiles
--------- --------
1108810   2

name: tsm1_wal
tags: database=_internal, engine=tsm1, id=23, indexType=inmem, path=C:\Users\Mat
ej Streznik\.influxdb\data\_internal\monitor\23, retentionPolicy=monitor, walPat
h=C:\Users\Matej Streznik\.influxdb\wal\_internal\monitor\23
currentSegmentDiskBytes oldSegmentsDiskBytes writeErr writeOk
----------------------- -------------------- -------- -------
830755                  0                    0        5015

name: write
pointReq pointReqLocal req    subWriteDrop subWriteOk writeDrop writeError write
Ok writeTimeout
-------- ------------- ---    ------------ ---------- --------- ---------- -----
-- ------------
2645407  2645407       223235 0            223235     0         0          22323
5  0

name: subscriber
createFailures pointsWritten writeFailures
-------------- ------------- -------------
0              0             0

name: cq
queryFail queryOk
--------- -------
0         0

name: httpd
tags: bind=:8086
authFail clientError fluxQueryReq fluxQueryReqDurationNs pingReq pointsWrittenDr
opped pointsWrittenFail pointsWrittenOK promReadReq promWriteReq queryReq queryR
eqDurationNs queryRespBytes recoveredPanics req     reqActive reqDurationNs   se
rverError statusReq writeReq writeReqActive writeReqBytes writeReqDurationNs
-------- ----------- ------------ ---------------------- ------- ---------------
----- ----------------- --------------- ----------- ------------ -------- ------
------------ -------------- --------------- ---     --------- -------------   --
--------- --------- -------- -------------- ------------- ------------------
0        187         0            0                      39      0
      0                 1517613         0           0            1358521  219678
737291500    180843953786   0               1563915 1         250461924796400 0
          0         205347   0              100952065     15949938485100
>

I’m certainly curious about the transaction rate, is that in there?

Network activity

Disk activity
image

It doesn’t seem a lot.

You may notice mongodb that UniFi Server application uses with about 10 - 25 writes per second and it uses only 1% cpu.

Matej

So your disc is getting written to 25kB/s … influx db accounting for “only” 3.5kB/s of that.

Seems like a fair traffic to me. What are you actually doing on this box? It’s not home automation.

Interesting, no reads. Should rule out Grafana contention.

My “box” does some home automation, but it mainly creates the interface for my devices like greenhouse controllers with full remote control via OH and telemetry history insight for regulation and actuators behavior. So that is why DB needs to store quite a lot of items frequently.

I am gonna experiment on test rig if different DB causes the same CPU load, which DB should I try that works with OH, and is not more complex to setup than Influx … (maybe MySQL, MongoDB).

Not sure if MySQL Trial expires, and if MongoDB is compatible with OH(as it has no persistence installation in paper UI) but @rlkoshak mentioned I could also try MongoDB.

Then I will decide if data rate needs to be optimized to store data like >> the extreme value(in + or -) of that minute, stored every minute. But not sure how to do that for multiple items easily.

Thanks Matej

I’m surprised. The “response time” on greenhouse environments is so long it doesn’t seem to warrant that frequent logging.