Tuning the OS
Tune the OSs of the physical machine and VM to improve server performance.
Physical Machine
Modify the GRUB parameters to tune the OS of the physical machine.
- Open the /etc/grub2-efi.cfg file.
vi /etc/grub2-efi.cfg
- Press i to enter the insert mode and add the following input/output memory management unit (IOMMU) configurations to the end of the kernel parameters:
iommu.passthrough=1 pci=realloc kvm-arm.vgic_v4_enable=1
kvm-arm.vgic_v4_enable=1 is applicable only to new Kunpeng 920 processor models.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Restart the physical machine OS for the configuration to take effect.
Virtual Machine
Configure huge page memory, enable cluster scheduling tuning, and optimize network performance, memory management, number of NIC queues and interrupt-core binding to tune the VM OS.
- Configure huge page memory for the VM.
- Open the /etc/grub2-efi.cfg file.
vi /etc/grub2-efi.cfg
- Press i to enter the insert mode. Add the following huge page configuration to the end of the kernel parameters:
default_hugepagesz=2M hugepagesz=2M hugepages=12500
- The setting of hugepages=12500 is based on a VM that is allocated with 32 GB memory.
- You are advised to set the value of hugepages to at least 75% of the actual VM memory.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Restart the VM OS for the configuration to take effect.
- Open the /etc/grub2-efi.cfg file.
- Enable cluster scheduling tuning.
- Optimize the network performance and memory management of the VM OS, and enable the scheduling tuning feature.
echo 8192 >/proc/sys/net/ipv4/tcp_max_syn_backlog echo 1024 >/proc/sys/net/core/somaxconn echo 16777216 >/proc/sys/net/core/rmem_max echo 16777216 >/proc/sys/net/core/wmem_max echo "4096 87380 16777216" >/proc/sys/net/ipv4/tcp_rmem echo "4096 65536 16777216" >/proc/sys/net/ipv4/tcp_wmem echo 360000 >/proc/sys/net/ipv4/tcp_max_syn_backlog echo 5 >/proc/sys/vm/dirty_ratio echo STEAL > /sys/kernel/debug/sched_features
- Optimize the number of NIC queues and interrupt-core binding.
Set the number of NIC queues to 1. Disable the irqbalance service to prevent unbalanced allocation of interrupts among different CPU cores.
systemctl stop irqbalance systemctl disable irqbalance ethtool -L ens6 combined 1
After the number of queues is set to 1, interrupts use one core by default. No additional interrupt-core binding operations are required.
Parent topic: MySQL Performance Tuning