Huge Pages improve memory access speed by using memory pages larger than the standard 4 KB size, typically 2 MB. These larger pages reduce Translation Lookaside Buffer (TLB) misses during memory address translation. However, allocating too many Huge Pages reduces the regular memory the Operating System can dynamically allocate. This can cause applications or system services that do not use Huge Pages to perform poorly or fail due to insufficient memory. If the Huge Pages setting for an instance is too high, this can cause the instance to become unreachable.
Procedure
Connect to the Linux Elastic Compute Service (ECS) instance using Virtual Network Computing (VNC).
For more information, see Connect to an instance using VNC.
To back up the
/etc/sysctl.conffile, run the following command.cp /etc/sysctl.conf /etc/sysctl.conf_bakTo edit the
/etc/sysctl.conffile, run the following command.sudo vim /etc/sysctl.confLocate the
vm.nr_hugepagesparameter and reduce its value to a reasonable level.You can calculate the required number of Huge Pages based on your application's memory requirements and the total system memory.Required number of Huge Pages = Memory required by the application / Size of one Huge Page. In Linux, the default Huge Page size is typically 2 MB. For example, if an application requires 16 GB of Huge Pages memory and the Huge Page size is 2 MB, the required number of pages is 16 GB / 2 MB = 8192. Modify the parameter as follows.vm.nr_hugepages = 8,192To apply the configuration, run the following command.
sudo sysctl -pVerify the change by checking the
/proc/meminfofile.cat /proc/meminfo
Reference
Alibaba Cloud Linux uses Transparent Huge Pages (THP) and Hugetext to improve system performance. For more information, see Hugetext.