You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# For databases and large-memory applications
cat /proc/meminfo | grep Huge
# Allocate 1024 hugepages (2MB each = 2GB)echo 1024 | sudo tee /proc/sys/vm/nr_hugepages
# Permanentecho"vm.nr_hugepages = 1024"| sudo tee -a /etc/sysctl.conf
# Transparent Hugepages (THP)
cat /sys/kernel/mm/transparent_hugepage/enabled
# Options: [always] madvise neverecho"madvise"| sudo tee /sys/kernel/mm/transparent_hugepage/enabled
OOM Killer Tuning
# View OOM score (higher = more likely to be killed)
cat /proc/$(pidof mysql)/oom_score
cat /proc/$(pidof mysql)/oom_score_adj
# Protect a process from OOM killerecho -1000 | sudo tee /proc/$(pidof mysql)/oom_score_adj
I/O Tuning
I/O Schedulers
# View current scheduler
cat /sys/block/sda/queue/scheduler
# [mq-deadline] kyber bfq none# Change schedulerecho"kyber"| sudo tee /sys/block/sda/queue/scheduler
Scheduler
Best For
mq-deadline
General purpose, databases (default)
kyber
Fast NVMe SSDs
bfq
Desktop interactive, USB drives
none
NVMe with hardware queues
Read-Ahead
# View/set read-ahead (KB)
blockdev --getra /dev/sda # Current value
sudo blockdev --setra 2048 /dev/sda # Set to 2048 sectors
Filesystem Mount Options
# /etc/fstab optimizations
UUID=xxx / ext4 noatime,nodiratime,discard 0 1
# noatime = don't update access times (big performance gain)# nodiratime = don't update directory access times# discard = enable TRIM for SSD (or use fstrim.timer)# Enable periodic TRIM
sudo systemctl enable fstrim.timer
# View current limitsulimit -a
ulimit -n # Open files limit# Increase permanently
sudo vim /etc/security/limits.conf
# * soft nofile 65536# * hard nofile 65536
🏋️ Practice Exercises
CPU: Change your CPU governor to performance and back
Memory: Tune swappiness to 10 and measure the effect
I/O: Check and change your disk scheduler
cgroups: Create a cgroup that limits a process to 50% CPU
tuned: Install tuned and apply throughput-performance profile
Limits: Increase the file descriptor limit to 65536
noatime: Add noatime to a mount and benchmark reads
Monitor: Use the USE method to analyze your system resources