-
Notifications
You must be signed in to change notification settings - Fork 492
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
Unexpected high system memory usage on single stream task #1586
Comments
Hi again, @nathanielc, @desa, we did the same test with Kapacitor 1.3.3 (git: master eacb373) and it seems to have the same behaviour explained on the comment above. Thanks, |
@sbengo Thanks for the report. What does the data that you're writing look like? How many tags, fields, etc.? Also the length of each of the tag keys and values would be useful. One thing that we can do to lower the amount of things buffered is only keep the fields we need in the window
I noticed that in our window node, we emit the data to the pipeline every minute with the last 30m
This means that every minute we send a 30m buffer of data down the pipeline. Internally this creates two ~30m windows of the data every minute so the math here is a bit off. This would also explain the leveling off at 1h. Nonetheless, with the adjustments to the equation, things are still a bit excessive. To summarize, I've got a couple asks
|
Thanks for the quick answer. In order to track which device/interface is giving errors, it is completely necessary to preserve the tags and show them on the
We will do the other proposed test on the following days. In order to provide more info, our data looks like: Data overview from measurement
As an example of one entry: TagSet (length in number of characters)
FieldSet (length in number of characters)
|
Keep only applies to fields. All tags will be preserved. I'd try to use the
Not sure I follow what you're trying to do. |
Hi @desa , first of all thanks for your reply. We did some test applying your suggestion of keeping only the 'InputUtilization' before the
Test 1 - 2017/09/29 :
Observations:
Test 2 - 2017/09/29:We activated another task to eval on the same measurement another field:
Observations:
Test 3 - 2017/10/02
Observations:
Questions
Is not Kapacitor keeping data like the following example? If its right, the memory would increase for For example with a
Do you agree?
|
Hello again! I update the issue with another test: Test 4 - 2017/10/03In this Test, we set up 5 task with the same cardinality: 4025 point into the same measurement and selecting different fields from the same time series (all fields are sent in the same write action) We modified the TickScript: instead of using 3 different vars we defined the tickscript calling the stream node and chaining them
Observations:
Questions
|
Hi @desa, @nathanielc I'm working with @sbengo in these analysis and we have decided repeat the test but now we have disabled all other running tasks and measured the Process "Heap In use" Instead of System Memory, as a more reliable way to measure memory consumption. As in the previous tests , we need compute the mean of 15 minutes of "InputUtilization" on aprox 4029 switch port interfaces and after we will compare them with some thresholds, we have also used an UDF (monInjector) to inject some fields (mon_activo,mon_linia,mon_exc) taken from an external(not influxdb) database, to control whether to continue with threshold evaluation and to select the among 3 different possible thresholds, also have hour/weekday filtering. TestTest 1: Original Template
When enabling this tasks we can see this consumption.
Test 2 ( windows + mean -> movingAverage)In this test we have removed the window node, and replaced the mean() node for the movingAverage() with 15 points (our resolution is 1point/minute). The result should be the same as the Test 1.
When enabled the task with this new TickScript this is the result
This test show us how memory increases a lot after 15 minutes when movingAverage node begins to send data to the following nodes. Test 3 . (no httpOut)In this test we have removed the, not needed httpOut() nodes
When enabled these are the results
When removed httpOut() the Heap peaks have disappeared. Test 4 ( 9 to 5 nodes)In this test we have removed all unneeded nodes and moved the related logic ( time checking, and some other checking) to our UDF (monInjector). With this logic change , we have reduced from 9 nodes to 5
When enabled the node we can see this behaviour.
Conclusions
We have reduced from initial 9299bytes/point to 720b/point , by reducing number of nodes ( and also moving logic to our external UDF) It seems like nodes after movingAverage (monInjector and Alert) are consuming such as movingAverage itself , but any of them stores data in memory ) Anyway we think 720 bytes/point is to much to a point where the sum of all tags/fields is about 200 bytes ( supposing each point are completely stored on memory although Tags have always the same values ) Remember we have working with this set of data. TagSet (length in number of characters)
Original FieldSet (length in number of characters)
Injected FieldSet from monInjector UDF Node (length in number of characters)
QuestionsI would like to understand how memory is handled in kapacitor in order to optimise the resource consumption for all our dataset ( lots of products with aprox 400 measurements sometimes with cardinality near 50000) . We need also sometimes compute online , averaged data for several hours ( 1 , 2 , 3) .
Thank you for your great work and We hope we can help you to improve it with our tests. |
Test 5 ( change monInjectorUDF to default())As a last test trying to release memory , we have removed completely the UDF functionality by a default node witch will inject 4 default fields ( as UDF did before). With this tickScript.
When enabled the node we can see this behaviour.
As we can see this change does not affect to much to the memory consumption. Still the same questions than before. QuestionsI would like to understand how memory is handled in kapacitor in order to optimise the resource consumption for all our dataset ( lots of products with aprox 400 measurements sometimes with cardinality near 50000) . We need also sometimes compute online , averaged data for several hours ( 1 , 2 , 3) .
|
Hello @sbengo @toni-moreno , this is a great analysis. Thanks! I'll answer your questions below.
Yes, in most cases Kapacitor stores the data as its written via the API, so if each point has repeated tags it is duplicated. There are cases where we know that the tags will not be used and we can drop them. Your use of
My answer above address this as well.
Currently movingAverage is storing as little data as possible(which equates to a slice of floats the size of moving average). Do you have another algorithm in mind?
In general each node will have to store the metadata about each unique group. So as you saw reducing the number of nodes can reduce the overall memory usage. For that reason the
Yes, it would be helpful to get a heap profile after the task is in its steady state. This can be retrieved by making this request.
In order for us to be able to read the profile data we need to exact commit that you are running. If you are still on 1.3.3 great, if not we will need to know. You can share the profile here if you want or feel free to send me the file directly. The file is a simple text file so you can inspect it for any sensitive data first. My contact info can be found on my github profile. Thanks again for the detailed write up. |
Hi @nathanielc About hpprofI've uploaded the pprof file for version Kapacitor 1.3.3 (git: master eacb373) kapacitor-heap.pprof-20171010.gz About recursive formulas.I've coded myself a new aggregator for telegraf (influxdata/telegraf#2167) we can use recursive formulas for some basic statistics like (count, sum,max,min,mean,variance,standard deviation), this node will need apply a "reset" on its internal counter once a group of points have been reached", it will lose output resolution , because of you will have one output point for each group of input points. But for much of our alert rules could be a good solution allowing saving memory resources. What do you thing about creating a special perhaps something like:
What do you think about? |
@toni-moreno Thanks for the pprof file. There seems to be a lot of the in use RAM relating to prometheus scrapping specifically AWS. Does that sound right? Have you configured Kapacitor to scrape AWS hosts? On Recursive formulasThe function in InfluxQL are nearly all implemented using this idea of consuming a single point at a time, and reducing the result as it goes along. The problem is that the window node is currently a bit naive. The window node could be optimized such that if its configured to be fixed non overlapping windows that it would immediately pass the data along only keeping track of metadata about the time of the points only. This would then take advantage of the reduce type function already implemented. In your example case though you have overlapping windows so the points that are part of the overlapping windows must be cached so they can be sent in each new window. |
Hi @nathanielc we have not any Prometheus scrapping configured. In fact we have updated version with old 1.1 config file ( there is not any [[scraper]] section in this file). After updated with all new sections like [[scraper]] , [[azure]], and others , and restarted I've repeated the last test. Test 6 ( added [[scraper]] enabled = false to the conf file ).
no changes on the memory consumption/point with this test, only initial memory has decreased some 10Mb. On Recursive formulasAbout recursive formulas I've not understand your explanation ( sorry perhaps my poor English has contributed on this). On the recursive implementation we assume we won't have overlapped window. In this approach if we would like to compute the mean of 15 points we will need only a counter (15 to 0 ) once it reaches 0 it should emit to the next node the computed average and reset values), and the last computed average. In the last example for 60 input points it will emit 4 output points , and assuming 8 bytes/point we have saved 87% of memory (from 120 bytes to 16 bytes)
We have lost resolution but saved a lot of memory , on most cases could be a great solution and will save memory when computed for >2 points . What do you think about this new approach? |
Hi @nathanielc suppose we would like to help you coding a new "like" influxQLNode recursiveStats as described before for basic stats which we can compute in a recursive way. These could be the statistics got (with one counter for number of points or time controller)
Would you like to add as a new Node in Kapacitor in next releases ? These could be the statistics got (with one counter for number of points or time controller)
Would you like to add as a new Node in Kapacitor in next releases ? |
Hi,
I'm working with Kapacitor 1.3.1 (git: master 3b5512f) to create some alerts with an InfluxDB subscription and after working on databases and several TickScripts we noticed an unusual high memory usage.
We have only enabled one task predefined with a template and filled with JSON which is retrieving data from
stream
mode to:every 1m
of30m windowed
ofInputUtilization
in everyinterface
of everyswitch
.InputUtilization
, so, sometimes error on mean nodes could appear.Example case
After enabling the task and see that it works OK, we have seen that the used system memory increased to unexpected level since we started Kapacitor and it reaches a constant level after 1 hour of working.
Assuming it keeps the data for 30min (window .period())
30 min * 4024 series * 1 point/1min = 120720 points over 30 min of data
, it seems each point is using1,078GB / 120720 points = 9588 bytes
. We think this is too much memory and we can not understand why Kapacitor requires this amount of memory for each point.We don't understand why the used system memory reaches the max level after 1 hour if only windowing points with interval set up with 30m duration.
Questions
With the behaviour explained above:
Does kapacitor need 10Kb of data to store each point of data on stream mode ?
Assuming linear scaling and the same cardinality, for only
N
task, we would needN * 1GB
of memory?Could you help us to understand Kapacitor memory behaviour, please ?
We attach you the following TickScripts and show statistics to let you check if there is something wrong on our TickScript/Nodes definition:
TickScript + node info
The following table is the brief of nodes cardinality and the diagram:
Note: Sometimes there is an error on the
mean node
because the field on the point does not exist.The text was updated successfully, but these errors were encountered: