influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

[0.9.0]: High CPU usage

Open dtouzeau opened this issue 11 years ago • 24 comments

Using a database with 6.0GB of data Processes eat all CPU

screenshot_2015-06-17-15-14-44

How can i help you to fix this issue ?

dtouzeau avatar Jun 17 '15 15:06 dtouzeau

@dtouzeau There is no one simple reason why the database would be using a lot of CPU. We need a great deal more information before we can even determine if this is an issue or expected behavior.

How many points per second are you writing to the database? Are you using the line protocol or JSON? How many points per batch? Single-node or cluster? Host OS, installed RAM, CPU, and storage media? (SSD or spinning platter?) How many ad-hoc queries are you running? How many continuous queries are set up? What is the cardinality of your tags?

beckettsean avatar Jun 17 '15 18:06 beckettsean

How many points per second are you writing to the database?

it is around 30-50 per second

Are you using the line protocol or JSON?

it is the line protocol

Single-node or cluster?

single node

Host OS, installed RAM, CPU, and storage media? (SSD or spinning platter?)

Virtual machine 4 CPUs, 6GB memory

How many ad-hoc queries are you running? None How many continuous queries are set up? None What is the cardinality of your tags?
tags are strings it is a proxy server here a piece of my code that inject in realtime proxy requests:

        $zArray["tags"]["CATEGORY"]=$GLOBALS["CACHEDUSersMem"][$KEYMD5]["CATEGORY"];
        $zArray["tags"]["USERID"]=$GLOBALS["CACHEDUSersMem"][$KEYMD5]["USERID"];
        $zArray["tags"]["IPADDR"]=$GLOBALS["CACHEDUSersMem"][$KEYMD5]["IPADDR"];
        $zArray["tags"]["MAC"]=$GLOBALS["CACHEDUSersMem"][$KEYMD5]["MAC"];
        $zArray["fields"]["SIZE"]=intval($GLOBALS["CACHEDUSersMem"][$KEYMD5]["SIZE"]);
        $zArray["tags"]["SITE"]=$GLOBALS["CACHEDUSersMem"][$KEYMD5]["SITE"];
        $zArray["tags"]["FAMILYSITE"]=$GLOBALS["CACHEDUSersMem"][$KEYMD5]["FAM"];
        $zArray["fields"]["ZDATE"]=time();
        $zArray["fields"]["RQS"]=intval($GLOBALS["CACHEDUSersMem"][$KEYMD5]["RQS"]);
        $zArray["tags"]["proxyname"]=$GLOBALS["MYHOSTNAME"];

This array is transformed to a line query to influxdb

dtouzeau avatar Jun 17 '15 19:06 dtouzeau

Please be aware that we on the core team are currently investigating high IO loads generated by InfluxDB, even when writing modest amounts of data. We believe there may be significant efficiency improvements available, when it comes to how we use the underlying data store (BoltDB). This may address any performance issues you are seeing.

otoolep avatar Jun 17 '15 19:06 otoolep

If i understand, we have to wait BoltDB implementation to fix High CPU usage ? Do you expect a release date (version number) ? Is there any upgrade data process planned to transfer old data to this new data store ? Because we have migrated from RCx to release and this needs to loose data history.

dtouzeau avatar Jun 17 '15 20:06 dtouzeau

We don't have a date yet, as work is ongoing.

Any future releases of 0.9 software will have an upgrade path, if one is required, so you won't lose any data.

otoolep avatar Jun 17 '15 21:06 otoolep

It is possible the fix will involve changes to BoltDB, but @benbjohnson, the maintainer of BoltDB, is on the InfluxDB core team, so there should be very little friction on any interdependencies there.

beckettsean avatar Jun 17 '15 21:06 beckettsean

Many Thanks for the feedback, really appreciate it... Your DB is very great... I has see servers, some are overloaded by Influx and applications around are unusable. Suggest to make this fix in priority... May be you have already done...

dtouzeau avatar Jun 17 '15 23:06 dtouzeau

single server single influxdb 0.90 I send 5000 point/s to influxdb and POST size about 700k/s I empty the DB and starting write data,I run about half an hour ,the IO is total bad but the wr_sec is very high even at first I using sar -d 1 3 Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util Average: dev8-0 74.73 334.07 8706.23 120.98 0.01 0.16 0.09 0.70 Average: dev8-16 10487.91 0.00 96202.20 9.17 2.01 0.19 0.01 10.15 Average: dev253-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Average: dev253-1 70.33 0.00 6587.55 93.67 0.01 0.14 0.08 0.59 Average: dev253-2 14.29 334.07 2118.68 171.69 0.00 0.15 0.10 0.15 Average: dev253-3 10487.91 0.00 96202.20 9.17 2.04 0.19 0.01 10.18 the wr_sec/s is very high,IO is very high

huhongbo avatar Jun 23 '15 05:06 huhongbo

On the subject of heavy IO, we're currently working on a solution for that. We will hopefully get this work done for the 0.9.2 release on July 23rd. In the meantime you can write against the API and now that it will remain stable.

Also, there will be an upgrade path from 0.9.0 and 0.9.1 to 0.9.2 so that you won't lose any of your data. We've committed to not making any breaking changes to the API or underlying data store in the 0.9 series of releases and we mean to keep that promise.

pauldix avatar Jun 24 '15 19:06 pauldix

Great!!!

dtouzeau avatar Jun 24 '15 21:06 dtouzeau

@dtouzeau did you have authentication enabled on your DB? If so, then the high CPU problem would be fixed by #3161, which will be in 0.9.1-rc2

pauldix avatar Jun 26 '15 22:06 pauldix

I have similar problem with high IO (with small data):

about 356M bytes of ingress traffic with 2 days uptime and:

lxc-top
Container            CPU      CPU      CPU      BlkIO        Mem
Name                Used      Sys     User      Total       Used
influxdb         1333.86   218.59   959.24   99.37 GB  794.77 MB

It does not take up much space:

[root@influxdb ~]# du -sh /var/opt/influxdb/data
664M    /var/opt/influxdb/data

I will wait for the 0.9.2 release :)

hordecore avatar Jun 27 '15 09:06 hordecore

@pauldix No i did not have any authentication added...

dtouzeau avatar Jun 27 '15 23:06 dtouzeau

Can you test the IO issue against 0.9.1?

On Jun 27, 2015, at 2:02 AM, Oleg Strizhechenko [email protected] wrote:

I have similar problem with high IO (with small data):

about 356M bytes of ingress traffic with 2 days uptime and:

lxc-top Container CPU CPU CPU BlkIO Mem Name Used Sys User Total Used influxdb 1333.86 218.59 959.24 99.37 GB 794.77 MB It does not take up much space:

[root@influxdb ~]# du -sh /var/opt/influxdb/data 664M /var/opt/influxdb/data I will wait for the 0.9.2 release :)

— Reply to this email directly or view it on GitHub.

pauldix avatar Jun 27 '15 23:06 pauldix

I have 0.9.1rc running and am not seeing much improvement in the write performance. The disk is still frequently hitting 2500 wr/sec for sustained periods, and select queries seem to get progressively slower, even on a fresh DB only a few hours old. A small log excerpt:

[shard] 2015/06/27 23:57:22 flush 132602 points in 29.628s
[collectd] 2015/06/27 23:57:30 failed to write batch: timeout
[collectd] 2015/06/27 23:57:40 failed to write batch: timeout
[shard] 2015/06/27 23:57:45 flush 158030 points in 21.413s
[collectd] 2015/06/27 23:57:50 failed to write batch: timeout
[collectd] 2015/06/27 23:58:00 failed to write batch: timeout
[collectd] 2015/06/27 23:58:10 failed to write batch: timeout
[shard] 2015/06/27 23:58:19 flush 213099 points in 32.200s
[collectd] 2015/06/27 23:58:20 failed to write batch: timeout
[collectd] 2015/06/27 23:58:30 failed to write batch: timeout
[collectd] 2015/06/27 23:58:40 failed to write batch: timeout
[shard] 2015/06/27 23:58:49 flush 247406 points in 28.054s

Collectd batching config is batch-size = 100000, batch-timeout = "10s".

dswarbrick avatar Jun 28 '15 00:06 dswarbrick

What if you reduce the batch size to 5k? 100k batches are way too big

On Jun 27, 2015, at 5:12 PM, Daniel Swarbrick [email protected] wrote:

I have 0.9.1rc running and am not seeing much improvement in the write performance. The disk is still frequently hitting 2500 wr/sec for sustained periods, and select queries seem to get progressively slower, even on a fresh DB only a few hours old. A small log excerpt:

[shard] 2015/06/27 23:57:22 flush 132602 points in 29.628s [collectd] 2015/06/27 23:57:30 failed to write batch: timeout [collectd] 2015/06/27 23:57:40 failed to write batch: timeout [shard] 2015/06/27 23:57:45 flush 158030 points in 21.413s [collectd] 2015/06/27 23:57:50 failed to write batch: timeout [collectd] 2015/06/27 23:58:00 failed to write batch: timeout [collectd] 2015/06/27 23:58:10 failed to write batch: timeout [shard] 2015/06/27 23:58:19 flush 213099 points in 32.200s [collectd] 2015/06/27 23:58:20 failed to write batch: timeout [collectd] 2015/06/27 23:58:30 failed to write batch: timeout [collectd] 2015/06/27 23:58:40 failed to write batch: timeout [shard] 2015/06/27 23:58:49 flush 247406 points in 28.054s Collectd batching config is batch-size = 100000, batch-timeout = "10s".

— Reply to this email directly or view it on GitHub.

pauldix avatar Jun 28 '15 00:06 pauldix

I originally had batch-size set to 30000. Setting it to 5000 is perhaps a little better, but it's still getting batch write timeouts. Disk is still spending about 80% of the time pegged at > 2200 IOPS.

[collectd] 2015/06/28 00:45:36 failed to write batch: timeout
[shard] 2015/06/28 00:45:39 flush 19966 points in 6.913s
[collectd] 2015/06/28 00:45:41 failed to write batch: timeout
[shard] 2015/06/28 00:45:44 flush 17894 points in 5.649s
[collectd] 2015/06/28 00:45:46 failed to write batch: timeout
[shard] 2015/06/28 00:45:50 flush 15748 points in 5.044s
[collectd] 2015/06/28 00:45:51 failed to write batch: timeout
[shard] 2015/06/28 00:45:55 flush 14739 points in 4.867s
[collectd] 2015/06/28 00:45:56 failed to write batch: timeout
[shard] 2015/06/28 00:45:59 flush 12473 points in 4.402s
[collectd] 2015/06/28 00:46:01 failed to write batch: timeout
[shard] 2015/06/28 00:46:06 flush 10804 points in 6.365s

I have sysstat collecting basic host metrics, and sar -dp shows:

00:00:01          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
00:05:01          vdb   1799.53      0.03  19586.98     10.88    101.47     56.37      0.45     80.94
00:15:01          vdb   1811.99      0.01  19903.60     10.98    102.19     56.41      0.45     81.46
00:25:01          vdb   1726.08      0.03  19390.27     11.23     97.13     56.27      0.45     77.77
00:35:01          vdb   1473.41      0.00  15648.51     10.62     81.10     55.03      0.45     65.76
00:45:01          vdb   1349.80      0.00  14631.33     10.84     73.86     54.72      0.45     60.52
Average:          vdb   1613.57      0.01  17637.21     10.93     90.00     55.78      0.45     72.44

dswarbrick avatar Jun 28 '15 00:06 dswarbrick

I have reduced the number of injected points ( using my own program to compress hourly points) It's divide points by 5 But server with 4 CPUs and 8GB of memory is still in crazy mode in 0.9.1 rc and is unavailable.... Expected seriously the 0.9.2 release.

1435586696566

dtouzeau avatar Jun 29 '15 22:06 dtouzeau

We must stop using InfluxDB, I/O storm and CPU usage crash the system. ( with 8 processors and 16GB memory)... Database is unusable Wait the 0.9.2 release

dtouzeau avatar Jul 01 '15 15:07 dtouzeau

@dtouzeau -- are you using authentication when posting data to the system?

otoolep avatar Jul 01 '15 16:07 otoolep