I’m trying to figure out how GKE reserves memory based on machine type.
From the docs, it reserves memory based on the following calculation :
- 255 MiB of memory for machines with less than 1 GB of memory
- 25% of the first 4GB of memory
- 20% of the next 4GB of memory (up to 8GB)
- 10% of the next 8GB of memory (up to 16GB)
- 6% of the next 112GB of memory (up to 128GB)
- 2% of any memory above 128GB
I’m unsure as to what upto 8GB means.
Lets say I have a n1-standard-16
machine with 60 GB Memory and 16 Cores.
25% of 4GB = 1GB (covered first 4GB)
20% of next 4GB = 0.8 GB (covered next 4GB or should it be 8? whats the meaning of upto 8 GB here?)
10% 0f next 8GB = 0.8
6% of next 112 GB = 6% of remaining i.e 44(since we don't have 112 GB )= 2.64
reserved_memory = 1+0.8+0.8+ 2.64 = 5.24
reserved_memory = 5.24 + 100MB (eviction threshold) + 100MB (OS reserved) = 5.44
total - reserved_memory = 54.56 GB is the allocatable memory?
Same goes for CPU reservartions
- 6% of the first core
- 1% of the next core (up to 2 cores)
- 0.5% of the next 2 cores (up to 4 cores)
- 0.25% of any cores above 4 cores
with 16 Cores we can calculate the following:
6% of first core = 0.6 (60 milicores)
1% of next core = 0.01 (10 milicores) (again here, what is upto 2 cores?)
0.5% of next 2 cores = 0.01 (10 milicores) (upto 4 cores)
0.25% of remaining 12 cores = 0.03 (30 milicores)
reserved = 100 milicores
total - reserved = 160000 - 100 = 15900 milicores
Somewhat similar calculation is followed by AKS and EKS as well.