kubernetes worker node with hugepages

What are hugepages?

For example, x86 CPUs normally
support 4K and 2M (1G if architecturally supported) page sizes, ia64
architecture supports multiple page sizes 4K, 8K, 64K, 256K, 1M, 4M, 16M,
256M and ppc64 supports 4K and 16M. A TLB is a cache of virtual-to-physical translations. Typically this is a very scarce resource on processor. Operating systems try to make best use of limited number of TLB resources. This optimization is more critical now as bigger and bigger physical memories (several GBs) are more readily available.

https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt

How to configure huge pages

clyso@compute-21:~$ grep Hugepagesize /proc/meminfo
Hugepagesize: 2048 kB
clyso@compute-21:~$
echo 1024 > /proc/sys/vm/nr_hugepages
echo "vm.nr_hugepages=1024" > /etc/sysctl.d/hugepages.conf

total huge pages

clyso@compute-21:/etc/sysctl.d# grep HugePages_Total /proc/meminfo
HugePages_Total: 1024
clyso@compute-21:/etc/sysctl.d#

free hugepages

clyso@compute-21:/etc/sysctl.d# grep HugePages_Free /proc/meminfo
HugePages_Free: 1024
clyso@compute-21:/etc/sysctl.d#

free memory

clyso@compute-21:/etc/sysctl.d# grep MemFree /proc/meminfo
MemFree: 765177380 kB
clyso@compute-21:/etc/sysctl.d#

How to make huge pages available in kubernetes?

restart kubernetes kublet on worker node

sudo systemctl restart kubelet.service

verify in kubernetes

Allocated resources

clyso@compute-21:~$ kubectl describe node compute-21 | grep -A 8 "Allocated resources:"
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests      Limits
  --------           --------      ------
  cpu                4950m (10%)   15550m (32%)
  memory             27986Mi (3%)  292670Mi (37%)
  ephemeral-storage  0 (0%)        0 (0%)
  hugepages-1Gi      0 (0%)        0 (0%)
  hugepages-2Mi      400Mi (19%)   400Mi (19%)
clyso@compute-21:~$

Capacity

clyso@compute-21:~$ kubectl describe node compute-21 | grep -A 13 "Capacity:"
Capacity:
  cpu:                48
  ephemeral-storage:  1536640244Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      2Gi
  memory:             792289900Ki
  pods:               110
Allocatable:
  cpu:                48
  ephemeral-storage:  1416167646526
  hugepages-1Gi:      0
  hugepages-2Mi:      2Gi
  memory:             790090348Ki
  pods:               110
clyso@compute-21:~$

Sources:

https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/

https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/sect-oracle_9i_and_10g_tuning_guide-large_memory_optimization_big_pages_and_huge_pages-configuring_huge_pages_in_red_hat_enterprise_linux_4_or_5

WordPress Cookie Notice by Real Cookie Banner