Skip to content

Commit

Permalink
feat(docs): Support MathJax && Refactor HPA, crane-scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
zsnmwy committed May 18, 2022
1 parent d9942fe commit bd3b535
Show file tree
Hide file tree
Showing 36 changed files with 330 additions and 148 deletions.
16 changes: 16 additions & 0 deletions docs/assets/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.typesetPromise()
})
1 change: 1 addition & 0 deletions docs/assets/output/chtml.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/output/chtml/fonts/tex.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions docs/assets/output/svg.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/output/svg/fonts/tex.js

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions docs/assets/polyfill.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/tex-mml-chtml.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion docs/assets/util.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.md-nav__title {
display: none;
}
}

.arithmatex {
font-size: 0.85rem;
}
57 changes: 37 additions & 20 deletions docs/tutorials/hpa-recommendation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HPA Recommendation

Using hpa recommendations, you can find resources in the cluster that are suitable for autoscaling, and use Crane's recommended result to create an autoscaling object: [Effective HorizontalPodAutoscaler](using-time-series-prediction.md).
Using hpa recommendations, you can find resources in the cluster that are suitable for autoscaling, and use Crane's recommended result to create an autoscaling object: [Effective HorizontalPodAutoscaler](using-effective-hpa-to-scaling-with-effectiveness.md).

## Create HPA Analytics

Expand Down Expand Up @@ -178,25 +178,40 @@ In the advising phase, one EffectiveHPA Spec is recommended using the following

Principle: Use Pod P99 resource utilization to recommend hpa. Because if the application can accept this utilization over P99 time, it can be inferred as a target for elasticity.

1. Get the Pod P99 usage of the past seven days by Percentile algorithm: pod_cpu_usage_p99
2. Corresponding utilization: target_pod_CPU_utilization = pod_cpu_usage_p99 / pod_cpu_request
1. Get the Pod P99 usage of the past seven days by Percentile algorithm: $pod\_cpu\_usage\_p99$
2. Corresponding utilization:

$target\_pod\_CPU\_utilization = \frac{pod\_cpu\_usage\_p99}{pod\_cpu\_request}$

3. To prevent over-utilization or under-utilization, target_pod_cpu_utilization needs to be less than ehpa.min-cpu-target-utilization and greater than ehpa. max-cpu-target-utilization

$ehpa.max\mbox{-}cpu\mbox{-}target\mbox{-}utilization < target\_pod\_cpu\_utilization < ehpa.min\mbox{-}cpu\mbox{-}target\mbox{-}utilization$

**Recommend minReplicas**

Principle: MinReplicas are recommended for the lowest hourly workload utilization for the past seven days.

1. Calculate the lowest median workload cpu usage of the past seven days: workload_cpu_usage_medium_min
2. Corresponding replicas: minReplicas = workload_cpu_usage_medium_min / pod_cpu_request / ehpa.max-cpu-target-utilization
1. Calculate the lowest median workload cpu usage of the past seven days: $workload\_cpu\_usage\_medium\_min$
2. Corresponding replicas:

$minReplicas = \frac{\mathrm{workload\_cpu\_usage\_medium\_min} }{pod\_cpu\_request \times ehpa.max-cpu-target-utilization}$

3. To prevent the minReplicas being too small, the minReplicas must be greater than or equal to ehpa.default-min-replicas

$minReplicas \geq ehpa.default\mbox{-}min\mbox{-}replicas$

**Recommend maxReplicas**

Principle: Use workload's past and future seven days load to recommend maximum replicas.

1. Calculate P95 workload CPU usage for the past seven days and the next seven days: workload_cpu_usage_p95
2. Corresponding replicas: max_replicas_origin = workload_cpu_usage_p95 / pod_cpu_request / target_cpu_utilization
3. To handle with the peak traffic, Magnify by a certain factor: max_replicas = max_replicas_origin * ehpa.max-replicas-factor
1. Calculate P95 workload CPU usage for the past seven days and the next seven days: $workload\_cpu\_usage\_p95$
2. Corresponding replicas:

$max\_replicas\_origin = \frac{\mathrm{workload\_cpu\_usage\_p95} }{pod\_cpu\_request \times target\_cpu\_utilization}$

3. To handle with the peak traffic, Magnify by a certain factor:

$max\_replicas = max\_replicas\_origin \times ehpa.max\mbox{-}replicas\mbox{-}factor$

**Recommend MetricSpec(except CpuUtilization)**

Expand All @@ -214,15 +229,17 @@ Principle: Use workload's past and future seven days load to recommend maximum r

## Configurations for HPA Recommendation

- ehpa.deployment-min-replicas: the default value is 1,hpa recommendations are not made for workloads smaller than this value
- ehpa.statefulset-min-replicas: the default value is 1,hpa recommendations are not made for workloads smaller than this value
- ehpa.workload-min-replicas: the default value is 1,Workload replicas smaller than this value are not recommended for hpa.
- ehpa.pod-min-ready-seconds: the default value is 30,specifies the number of seconds in decide whether a POD is ready.
- ehpa.pod-available-ratio: the default value is 0.5,Workloads whose Ready pod ratio is smaller than this value are not recommended for hpa.
- ehpa.default-min-replicas: the default value is 2,the default minimum minReplicas.
- ehpa.max-replicas-factor: the default value is 3,the factor for calculate maxReplicas.
- ehpa.min-cpu-usage-threshold: the default value is 10, hpa recommendations are not made for workloads smaller than this value.
- ehpa.fluctuation-threshold: the default value is 1.5, hpa recommendations are not made for workloads smaller than this value.
- ehpa.min-cpu-target-utilization: the default value is 30
- ehpa.max-cpu-target-utilization: the default value is 75
- ehpa.reference-hpa: the default value is true, which means inherits the existing HPA configuration
| Configuration | Default Value | Description |
| ------------- | ------------- | ----------- |
| ehpa.deployment-min-replicas | 1 | hpa recommendations are not made for workloads smaller than this value. |
| ehpa.statefulset-min-replicas| 1 | hpa recommendations are not made for workloads smaller than this value. |
| ehpa.workload-min-replicas| 1 | Workload replicas smaller than this value are not recommended for hpa. |
| ehpa.pod-min-ready-seconds| 30 | specifies the number of seconds in decide whether a POD is ready. |
| ehpa.pod-available-ratio| 0.5 | Workloads whose Ready pod ratio is smaller than this value are not recommended for hpa. |
| ehpa.default-min-replicas| 2 | the default minimum minReplicas.|
| ehpa.max-replicas-factor| 3 | the factor for calculate maxReplicas. |
| ehpa.min-cpu-usage-threshold| 10| hpa recommendations are not made for workloads smaller than this value.|
| ehpa.fluctuation-threshold| 1.5 | hpa recommendations are not made for workloads smaller than this value.|
| ehpa.min-cpu-target-utilization| 30 | |
| ehpa.max-cpu-target-utilization| 75 | |
| ehpa.reference-hpa| true | inherits the existing HPA configuration |
57 changes: 37 additions & 20 deletions docs/tutorials/hpa-recommendation.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 弹性推荐

通过弹性推荐,你可以发现集群中适合弹性的资源,并使用 Crane 推荐的弹性配置创建自动弹性器: EffectiveHPA
通过弹性推荐,你可以发现集群中适合弹性的资源,并使用 Crane 推荐的弹性配置创建自动弹性器: [Effective HorizontalPodAutoscaler](using-effective-hpa-to-scaling-with-effectiveness.md)

## 创建弹性分析

Expand Down Expand Up @@ -178,25 +178,40 @@ status:

原理: 使用 Pod P99 资源利用率推荐弹性的目标。因为如果应用可以在 P99 时间内接受这个利用率,可以推断出可作为弹性的目标。

1. 通过 Percentile 算法得到 Pod 过去七天 的 P99 使用量: pod_cpu_usage_p99
2. 对应的利用率:target_pod_cpu_utilization = pod_cpu_usage_p99 / pod_cpu_request
1. 通过 Percentile 算法得到 Pod 过去七天 的 P99 使用量: $pod\_cpu\_usage\_p99$
2. 对应的利用率:

$target\_pod\_CPU\_utilization = \frac{pod\_cpu\_usage\_p99}{pod\_cpu\_request}$

3. 为了防止利用率过大或过小,target_pod_cpu_utilization 需要小于 ehpa.min-cpu-target-utilization 和大于 ehpa.max-cpu-target-utilization

$ehpa.max\mbox{-}cpu\mbox{-}target\mbox{-}utilization < target\_pod\_cpu\_utilization < ehpa.min\mbox{-}cpu\mbox{-}target\mbox{-}utilization$

**推荐 minReplicas**

原理: 使用 workload 过去七天内每小时负载最低的利用率推荐 minReplicas。

1. 计算过去7天 workload 每小时使用量中位数的最低值: workload_cpu_usage_medium_min
2. 对应的最低利用率对应的副本数: minReplicas = workload_cpu_usage_medium_min / pod_cpu_request / ehpa.max-cpu-target-utilization
1. 计算过去7天 workload 每小时使用量中位数的最低值: $workload\_cpu\_usage\_medium\_min$
2. 对应的最低利用率对应的副本数:

$minReplicas = \frac{\mathrm{workload\_cpu\_usage\_medium\_min} }{pod\_cpu\_request \times ehpa.max-cpu-target-utilization}$

3. 为了防止 minReplicas 过小,minReplicas 需要大于等于 ehpa.default-min-replicas

$minReplicas \geq ehpa.default\mbox{-}min\mbox{-}replicas$

**推荐 maxReplicas**

原理: 使用 workload 过去和未来七天的负载推荐最大副本数。

1. 计算过去七天和未来七天 workload cpu 使用量的 P95: workload_cpu_usage_p95
2. 对应的副本数: max_replicas_origin = workload_cpu_usage_p95 / pod_cpu_request / target_cpu_utilization
3. 为了应对流量洪峰,放大一定倍数: max_replicas = max_replicas_origin * ehpa.max-replicas-factor
1. 计算过去七天和未来七天 workload cpu 使用量的 P95: $workload\_cpu\_usage\_p95$
2. 对应的副本数:

$max\_replicas\_origin = \frac{\mathrm{workload\_cpu\_usage\_p95} }{pod\_cpu\_request \times target\_cpu\_utilization}$

3. 为了应对流量洪峰,放大一定倍数:

$max\_replicas = max\_replicas\_origin \times ehpa.max\mbox{-}replicas\mbox{-}factor$

**推荐CPU以外 MetricSpec**

Expand All @@ -214,15 +229,17 @@ status:

## 弹性分析计算配置

- ehpa.deployment-min-replicas: 默认值 1,小于该值的工作负载不做弹性推荐
- ehpa.statefulset-min-replicas: 默认值 1,小于该值的工作负载不做弹性推荐
- ehpa.workload-min-replicas: 默认值 1,小于该值的工作负载不做弹性推荐
- ehpa.pod-min-ready-seconds: 默认值 30,定义了 Pod 是否 Ready 的秒数
- ehpa.pod-available-ratio: 默认值 0.5,Ready Pod 比例小于该值的工作负载不做弹性推荐
- ehpa.default-min-replicas: 默认值 2,最小 minReplicas
- ehpa.max-replicas-factor: 默认值 3,计算 maxReplicas 的倍数
- ehpa.min-cpu-usage-threshold: 默认值 10, 小于该值的工作负载不做弹性推荐
- ehpa.fluctuation-threshold: 默认值 1.5, 小于该值的工作负载不做弹性推荐
- ehpa.min-cpu-target-utilization: 默认值 30
- ehpa.max-cpu-target-utilization: 默认值 75
- ehpa.reference-hpa: 默认值 true,继承现有的 HPA 配置
| 配置项 | 默认值 | 描述|
| ------------- | ------------- | ----------- |
| ehpa.deployment-min-replicas | 1 | 小于该值的工作负载不做弹性推荐 |
| ehpa.statefulset-min-replicas| 1 | 小于该值的工作负载不做弹性推荐 |
| ehpa.workload-min-replicas| 1 | 小于该值的工作负载不做弹性推荐 |
| ehpa.pod-min-ready-seconds| 30 | 定义了 Pod 是否 Ready 的秒数 |
| ehpa.pod-available-ratio| 0.5 | Ready Pod 比例小于该值的工作负载不做弹性推荐 |
| ehpa.default-min-replicas| 2 | 最小 minReplicas |
| ehpa.max-replicas-factor| 3 | 计算 maxReplicas 的倍数 |
| ehpa.min-cpu-usage-threshold| 10| 小于该值的工作负载不做弹性推荐 |
| ehpa.fluctuation-threshold| 1.5 | 小于该值的工作负载不做弹性推荐 |
| ehpa.min-cpu-target-utilization| 30 | |
| ehpa.max-cpu-target-utilization| 75 | |
| ehpa.reference-hpa| true | 继承现有的 HPA 配置 |
Loading

0 comments on commit bd3b535

Please sign in to comment.