You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2017/02/27 16:04:08 UTC
[5/8] storm git commit: More rework
More rework
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/debb3b81
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/debb3b81
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/debb3b81
Branch: refs/heads/master
Commit: debb3b81e88104fa63c21be473f883352ae13c03
Parents: 0d97375
Author: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Authored: Wed Feb 22 10:26:53 2017 -0600
Committer: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Committed: Wed Feb 22 10:26:53 2017 -0600
----------------------------------------------------------------------
docs/cgroups_in_storm.md | 52 ++++++++++++++++++--
.../storm/metric/cgroup/CGroupCpuGuarantee.java | 28 +++++------
2 files changed, 60 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/debb3b81/docs/cgroups_in_storm.md
----------------------------------------------------------------------
diff --git a/docs/cgroups_in_storm.md b/docs/cgroups_in_storm.md
index 5eac9dc..ce86d81 100644
--- a/docs/cgroups_in_storm.md
+++ b/docs/cgroups_in_storm.md
@@ -54,12 +54,12 @@ For a more detailed explanation of the format and configs for the cgconfig.conf
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/ch-Using_Control_Groups.html#The_cgconfig.conf_File
-To let storm manage the cgroups for indavidual workers you need to make sure that the resources you want to control are mounted under the same directory as in the example above.
+To let storm manage the cgroups for individual workers you need to make sure that the resources you want to control are mounted under the same directory as in the example above.
If they are not in the same directory the supervisor will throw an exception.
The perm section needs to be configured so that the user the supervisor is running as can modify the group.
-If run as user is enabled so the supervisor spawns other processes as the user that launched the topology make sure that the permissions are such that indavidual users have read access but not write access.
+If "run as user" is enabled so that the supervisor spawns other processes as the user that launched the topology, make sure that the permissions are such that individual users have read access but not write access.
# Settings Related To CGroups in Storm
@@ -81,7 +81,7 @@ CGroups can be used in conjunction with the Resource Aware Scheduler. CGroups w
# CGroup Metrics
-CGroups not only can limit the amount of resources a worker has access to, but it can also help monitor the resource consumption of a worker. There are several metrics enabled by default that will check if the worker is a part of a CGroup and report correspndign metrics.
+CGroups not only can limit the amount of resources a worker has access to, but it can also help monitor the resource consumption of a worker. There are several metrics enabled by default that will check if the worker is a part of a CGroup and report corresponding metrics.
## CGroupCPU
@@ -108,4 +108,48 @@ org.apache.storm.metric.cgroup.CGroupMemoryUsage reports the current memory usag
## CGroupMemoryLimit
-org.apache.storm.metric.cgroup.CGroupMemoryLimit report the current limit in bytes for all of the processes in the cgroup. If running with CGroups enabeld in storm this is the on-heap request + the off-heap request for all tasks within the worker + any extra slop space given to workers.
+org.apache.storm.metric.cgroup.CGroupMemoryLimit report the current limit in bytes for all of the processes in the cgroup. If running with CGroups enabled in storm this is the on-heap request + the off-heap request for all tasks within the worker + any extra slop space given to workers.
+
+## Usage/Debugging CGroups in your topology
+
+These metrics can be very helpful in debugging what has happened or is happening to your code when it is running under a CGroup.
+
+### CPU
+
+CPU guarantees under storm are soft. It means that a worker can ea sly go over their guarantee if there is free CPU available. To detect that your worker is using more CPU then it requested you can sum up the values in CGroupCPU and compare them to CGroupCpuGuarantee.
+If CGroupCPU is consistently higher then or equal to CGroupCpuGuarantee you probably want to look at requesting more CPU as your worker may be starved for CPU if more load is placed on the cluster. Being equal to CGroupCpuGuarantee means your worker may already
+be throttled. If the used CPU is much smaller than CGroupCpuGuarantee then you are probably wasting resources and may want to reduce your CPU ask.
+
+If you do have high CPU you probably also want to check out the GC metrics and/or the GC log for your worker. Memory pressure on the heap can result in increased CPU as garbage collection happens.
+
+### Memory
+
+Memory debugging of java under a cgroup can be difficult for multiple reasons.
+
+1. JVM memory management is complex
+2. As of the writing of this documentation only experimental support for cgroups is in a few JVMs
+3. JNI and other processes can use up memory within the cgroup that the JVM is not always aware of.
+4. Memory pressure within the heap can result in increased CPU load instead of increased memory allocation.
+
+There are several metrics that storm�provides by default that can help you understand what is happening within your worker.
+
+If CGroupMemory gets close to CGroupMemoryLimit then you know that bad things are likely to start happening soon with this worker. Memory is not a soft guarantee like CPU.
+If you go over the OOM killer on Linux will start to shoot processes withing your worker. Please pay attention to these metrics. If you are running a version of java that
+is cgroup aware then going over the limit typically means that you will need to increase your off heap request. If you are not, it could be that you need more off heap
+memory or it could be that java has allocated more memory then it should have as part of the garbage collection process. Figuring out which is typically best done with
+trial and error (sorry).
+
+Storm also reports the JVM's on heap and off heap usage through the "memory/heap" and "memory/nonHeap" metrics respectively. These can be used to give you a hint on
+which to increase. Looking at the "usedBytes" field under each can help you understand how much memory the JVM is currently using. Although, like I said the off heap
+portion is not always accurate and when the heap grows it can result in unrecorded off heap memory that will cause the cgroup to shoot processes.
+
+The name of the GC metrics vary based off of the garbage collector you use, but they all start with "GC/". If you sum up all of the "GC/*.timeMs" metrics for a given worker/window pair
+you should be able to see how much of the CPU guarantee went to GC. By default java allows 98% of cpu time to go towards GC before it throws an OutOfMemoryError. This is far from ideal
+for a near real time streaming system so pay attention to this ratio.
+
+If the ratio is at a fairly steady state and your memory usage is not even close to the limit you might want to look at reducing your memory request. This too can be complicated to figure
+out.
+
+## Future Work
+
+There is a lot of work on adding in elasticity to storm. Eventually we hope to be able to do all of the above analysis for you and grow/shrink your topology on demand.
http://git-wip-us.apache.org/repos/asf/storm/blob/debb3b81/storm-core/src/jvm/org/apache/storm/metric/cgroup/CGroupCpuGuarantee.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/metric/cgroup/CGroupCpuGuarantee.java b/storm-core/src/jvm/org/apache/storm/metric/cgroup/CGroupCpuGuarantee.java
index 47ac153..f663152 100644
--- a/storm-core/src/jvm/org/apache/storm/metric/cgroup/CGroupCpuGuarantee.java
+++ b/storm-core/src/jvm/org/apache/storm/metric/cgroup/CGroupCpuGuarantee.java
@@ -35,22 +35,18 @@ public class CGroupCpuGuarantee extends CGroupMetricsBase<Long> {
}
@Override
- public Long getDataFrom(CgroupCore core) {
- try {
- CpuCore cpu = (CpuCore)core;
- Long msGuarantee = null;
- long now = System.currentTimeMillis();
- if (previousTime > 0) {
- long shares = cpu.getCpuShares();
- //By convention each share corresponds to 1% of a CPU core
- // or 100 = 1 core full time. So the guaranteed number of ms
- // (approximately) should be ...
- msGuarantee = (shares * (now - previousTime))/100;
- }
- previousTime = now;
- return msGuarantee;
- } catch (IOException e) {
- throw new RuntimeException(e);
+ public Long getDataFrom(CgroupCore core) throws IOException {
+ CpuCore cpu = (CpuCore)core;
+ Long msGuarantee = null;
+ long now = System.currentTimeMillis();
+ if (previousTime > 0) {
+ long shares = cpu.getCpuShares();
+ //By convention each share corresponds to 1% of a CPU core
+ // or 100 = 1 core full time. So the guaranteed number of ms
+ // (approximately) should be ...
+ msGuarantee = (shares * (now - previousTime))/100;
}
+ previousTime = now;
+ return msGuarantee;
}
}