forked from kubernetes/autoscaler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aggregations_config.go
73 lines (64 loc) · 3.02 KB
/
aggregations_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package model
import (
"time"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/util"
)
var (
// MemoryAggregationWindowLength is the length of the memory usage history
// aggregated by VPA, which is 8 days.
MemoryAggregationWindowLength = time.Hour * 8 * 24
// MemoryAggregationInterval is the length of a single interval, for
// which the peak memory usage is computed.
// Memory usage peaks are aggregated in daily intervals. In other words
// there is one memory usage sample per day (the maximum usage over that
// day).
// Note: AggregationWindowLength must be integrally divisible by this value.
MemoryAggregationInterval = time.Hour * 24
// CPUHistogramOptions are options to be used by histograms that store
// CPU measures expressed in cores.
CPUHistogramOptions = cpuHistogramOptions()
// MemoryHistogramOptions are options to be used by histograms that
// store memory measures expressed in bytes.
MemoryHistogramOptions = memoryHistogramOptions()
// HistogramBucketSizeGrowth defines the growth rate of the histogram buckets.
// Each bucket is wider than the previous one by this fraction.
HistogramBucketSizeGrowth = 0.05 // Make each bucket 5% larger than the previous one.
// MemoryHistogramDecayHalfLife is the amount of time it takes a historical
// memory usage sample to lose half of its weight. In other words, a fresh
// usage sample is twice as 'important' as one with age equal to the half
// life period.
MemoryHistogramDecayHalfLife = time.Hour * 24
// CPUHistogramDecayHalfLife is the amount of time it takes a historical
// CPU usage sample to lose half of its weight.
CPUHistogramDecayHalfLife = time.Hour * 24
)
func cpuHistogramOptions() util.HistogramOptions {
// CPU histograms use exponential bucketing scheme with the smallest bucket
// size of 0.1 core, max of 1000.0 cores and the relative error of HistogramRelativeError.
options, err := util.NewExponentialHistogramOptions(1000.0, 0.1, 1.+HistogramBucketSizeGrowth, 0.1)
if err != nil {
panic("Invalid CPU histogram options") // Should not happen.
}
return options
}
func memoryHistogramOptions() util.HistogramOptions {
// Memory histograms use exponential bucketing scheme with the smallest
// bucket size of 10MB, max of 1TB and the relative error of HistogramRelativeError.
options, err := util.NewExponentialHistogramOptions(1e12, 1e7, 1.+HistogramBucketSizeGrowth, 0.1)
if err != nil {
panic("Invalid memory histogram options") // Should not happen.
}
return options
}