Skip to content

Commit 047eb68

Browse files
Add cpu doc
1 parent 4713199 commit 047eb68

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Kondense is an automated resource sizing tool. It runs as a sidecar in kubernete
1111
## Background
1212

1313
### Memory
14-
Kondense uses memory pressure to apply just the right amount of memory on a container to page out the unused memory while not getting out-of-memory killed.
14+
Kondense uses memory pressure to apply just the right amount of memory on a container to page out the unused memory while not getting out-of-memory killed.</br>[How is memory calculated ?](./doc/memory.md)
1515

1616
### CPU
17-
Kondense resizes CPU based on CPU usage, default to 80%.
17+
Kondense resizes CPU based on CPU usage, default to 80%.</br>[How is CPU calculated ?](./doc/cpu.md)
1818

1919
## Requirements
2020

doc/cpu.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# How is container CPU calculated ?
2+
Kondense resize each container CPU every second with the following steps.
3+
4+
## 1. Calculate average CPU usage of the container.
5+
Kondense calculate the average CPU usage over the last `INTERVAL` seconds. By default, `INTERVAL` is 10 seconds.
6+
7+
### 2. Calculate new CPU
8+
To calculate the new container CPU, we need the `TARGET_AVG`. By default, `TARGET_AVG` is 0.8 so 80%.
9+
10+
```
11+
new_cpu = average_cpu / TARGET_AVG
12+
```
13+
14+
### 2.1 If `new_cpu` is smaller than current container cpu limit
15+
16+
If `new_cpu` is smaller than the current container limit, we just patch container CPU limit with this `new_cpu`.
17+
18+
### 2.2 If `new_cpu` is bigger than current container cpu limit
19+
20+
If this `new_cpu` is higher than the current CPU container limit, we exponentially increase `new_cpu` with this formula:
21+
```
22+
new_cpu = new_cpu + (new_cpu * coeff)²
23+
```
24+
The bigger the `coeff`, the stronger Kondense will increase the CPU.
25+
We patch the container CPU limit with this `new_cpu`.

doc/memory.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# How is memory calculated ?
2+
will come soon

0 commit comments

Comments
 (0)