Boost MySQL Performance on Linux: CPU, Memory, and Filesystem Tuning Guide
This article outlines practical Linux‑based optimization techniques for MySQL, covering CPU power‑saving modes, NUMA and vm.swappiness settings, as well as mount options and I/O scheduler tweaks to maximize database throughput and stability.
Introduction
Most MySQL deployments run on Linux, and applying a few straightforward system‑level tweaks can noticeably improve MySQL performance. Below are practical strategies for CPU, memory, and filesystem optimization.
1. CPU
Modern CPUs use power‑saving modes that lower frequency when the system is idle, which can throttle MySQL. To ensure MySQL fully utilizes CPU resources, set the processor to maximum performance mode via BIOS or the operating system.
2. Memory
NUMA (Non‑Uniform Memory Access) architectures treat local and remote memory differently. On Linux you can control memory allocation policies, but the default interleaved mode may cause unnecessary swapping. The simplest solution is to disable NUMA and set vm.swappiness=0 so the kernel avoids swapping MySQL’s inactive pages.
Disable NUMA by adding numa=off to the kernel line in /etc/grub.conf (or the appropriate boot loader configuration) and rebuild the boot configuration.
Set vm.swappiness=0 by adding the line vm.swappiness=0 to /etc/sysctl.conf and applying it with sysctl -p.
3. Filesystem
Mount options noatime and nobarrier reduce unnecessary metadata updates and avoid write barriers that are often unnecessary on RAID or flash storage. Apply them when mounting ext3/ext4/reiserfs (use barrier=0) or xfs (use nobarrier).
For I/O scheduling, the deadline scheduler prevents long‑running requests from starving shorter ones, which is beneficial for database workloads. Set it temporarily with echo deadline > /sys/block/sda/queue/scheduler or permanently by adding elevator=deadline to the kernel line in /etc/grub.conf.
Summary
CPU: Disable power‑saving modes and run at maximum performance.
Memory: Disable NUMA, set vm.swappiness=0, and avoid swapping MySQL pages.
Filesystem: Mount with noatime and nobarrier, and use the deadline I/O scheduler.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
