Forked from tamirko/tomcat_auto_scaling.groovy
Last active
December 31, 2015 03:28
-
-
Save itaifrenkel/7927479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculates the sum of all instances metrics and divides by the number of instances (average) | |
instancesStatistics Statistics.average | |
// Selects the instance metric with the greatest value (maximum) | |
instancesStatistics Statistics.maximum | |
// Selects the instance metric with the smallest value (minimum) | |
instancesStatistics Statistics.minimum | |
// Selects the instance metric that is greater than 10% of the other metrics and | |
// smaller than 90% of the other metrics | |
instancesStatistics Statistics.percentile(10) | |
// Selects the instance metric that is greater than 50% of the other metrics | |
// and smaller than 50% of the other metrics (median) | |
instancesStatistics Statistics.percentile(50) | |
instancesStatistics Statistics.median |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shorthand for: | |
// timeStatistic average | |
// instancesStatistic average | |
statistics Statistics.averageOfAverages | |
// Shorthand for: | |
// timeStatistic average | |
// instancesStatistic maximum | |
statistics Statistics.maximumOfAverages | |
// Shorthand for: | |
// timeStatistic average | |
// instancesStatistic minimum | |
statistics Statistics.minimumOfAverages | |
// Shorthand for: | |
// timeStatistic average | |
// instancesStatistic percentile(10) | |
statistics Statistics.percentileOfAverages(10) | |
// Shorthand for: | |
// timeStatistic maximum | |
// instancesStatistic maximum | |
statistics Statistics.maximumOfMaximums | |
// Shorthand for: | |
// timeStatistic minimum | |
// instancesStatistic minimum | |
statistics Statistics.minimumOfMinimums | |
// Shorthand for: | |
// timeStatistic throughput | |
// instancesStatistic maximum | |
statistics Statistics.maximumThroughput | |
// Shorthand for: | |
// timeStatistic throughput | |
// instancesStatistic minimum | |
statistics Statistics.minimumThroughput | |
// Shorthand for: | |
// timeStatistic throughput | |
// instancesStatistic average | |
statistics Statistics.averageThroughput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculates the sum all metrics and divides by the number of metrics (average) | |
// during the specified time window | |
timeStatistics Statistics.average | |
// Selects the metric with the greatest value (maximum) | |
// during the specified time window | |
timeStatistics Statistics.maximum | |
// Selects the metric with the smallest value (minimum) | |
// during the specified time window | |
timeStatistics Statistics.minimum | |
// Selects the metric that is greater than 10% of the other metrics and | |
// smaller than 90% of the other metrics | |
// during the specified time window | |
timeStatistics Statistics.percentile(10) | |
// Selects the metric that is greater than 50% of the other metrics | |
// and smaller than 50% of the other metrics (median) | |
// during the specified time window | |
timeStatistics Statistics.percentile(50) | |
timeStatistics Statistics.median | |
// Calculates the average change per second during the specified time window. | |
// (lastMetric - firstMetric)/(lastMetricSeconds - firstMetricSeconds) | |
// Here is a throughput calculation example given the total number of requests metric | |
// during a 20 seconds time window: | |
// timestamp (seconds) | value(total number of requests) | |
// 0 | 1000 | |
// 5 | 1200 | |
// 10 | 1400 | |
// 15 | 1600 | |
// 20 | 1800 | |
// The throughput would be (1800-1000)/(20-0)= 1800/20= 90 requests per second | |
metric "Total Requests Count" | |
timeStatistics Statistics.throughput | |
// Calculates the average change per millisecond during the specified time window multiplied by 100. | |
// 100 * (lastMetric - firstMetric)/(lastMetricMilliseconds - firstMetricMilliseconds) | |
// The total CPU as provided by Sigar is the total number of milliseconds that the CPU was busy. | |
// Here is a CPU percentage calculation example given the total CPU: | |
// timestamp (ms) | value(total cpu as provided by sigar) | |
// 0 | 1000 | |
// 5000 | 1200 | |
// 10000 | 1400 | |
// 15000 | 1600 | |
// 20000 | 1800 | |
// The CPU percentage would be 100*(1800 - 1000)/(20000-0)= 100*0.04 = 4 | |
// If you would run top on that machine you would see the figure 4% | |
metric "Total Process Cpu Time" | |
timeStatistics Statistics.averageCpuPercentage | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service { | |
name "tomcat" | |
... | |
/* A global flag that enables changing the number of | |
instances for this service */ | |
elastic true | |
// the initial number of instances | |
numInstances 1 | |
/* The minimum number of service instances. | |
Used together with scaling rules */ | |
minAllowedInstances 1 | |
/* The maximum number of service instances. | |
Used together with scaling rules */ | |
maxAllowedInstances 2 | |
/* The time (in seconds) that scaling rules are disabled after | |
scale in (instances removed) or scale out (instances added). | |
This has the same effect as setting scaleInCooldownInSeconds | |
and scaleOutCooldownInSeconds separately. | |
Used together with scaling rules. | |
This attribute should be greater than or equal | |
to the movingTimeRangeInSeconds attribute | |
in the serviceStatistics section. | |
*/ | |
scaleCooldownInSeconds 20 | |
/* The time (in seconds) between two consecutive metric samples. | |
Used together with scaling rules */ | |
samplingPeriodInSeconds 1 | |
// Defines an automatic scaling rule based on "counter" metric value | |
scalingRules ([ | |
scalingRule { | |
serviceStatistics { | |
/* The name of the metric that is the basis | |
for the scale rule decision | |
In the current example, the metric we use is "Total Requests Count". | |
*/ | |
metric "Total Requests Count" | |
/* (Optional) | |
The sliding time range (in seconds) for | |
aggregating per-instance metric samples. | |
The number of samples in the time windows equals | |
the time window divided by the sampling period. | |
Default value: 300 */ | |
movingTimeRangeInSeconds 20 | |
/* (Optional) | |
The algorithms for aggregating metric samples by instances | |
and by time. Metric samples are aggregated separately | |
per instance in the specified time range,and then aggregated | |
again for all instances. | |
Default value: Statistics.averageOfAverages | |
Possible values: | |
Statistics.maximumOfAverages, | |
Statistics.minimumOfAverages, | |
Statistics.averageOfAverages, | |
Statistics.percentileOfAverages(90), | |
Statistics.maximumOfMaximums, | |
Statistics.minimumOfMinimums, | |
Statistics.maximumThroughput. | |
The following has the same effect as setting instancesStatistics | |
and timeStatistics separately. | |
For example: | |
statistics Statistics.maximumOfAverages | |
is the same as: | |
timeStatistics Statistics.average | |
instancesStatistics Statistics.maximum */ | |
statistics Statistics.maximumThroughput | |
} | |
highThreshold { | |
/* The value above which the number of instances is increased */ | |
value 1 | |
/* The number of instances to increase when above threshold */ | |
instancesIncrease 1 | |
} | |
lowThreshold { | |
/* The value below which the number of instances is decreased */ | |
value 0.2 | |
/* The number of instances to decrease when below threshold */ | |
instancesDecrease 1 | |
} | |
} | |
]) | |
plugins([ | |
plugin { | |
name "jmx" | |
className "org.cloudifysource.usm.jmx.JmxMonitor" | |
config([ | |
"Total Requests Count": [ | |
"Catalina:type=GlobalRequestProcessor,name=\"http-bio-8080\"", | |
"requestCount" | |
], | |
port: "11099" | |
]) | |
} | |
]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment