
Game Server Performance Tuning on Linux
- AuthorBen H.
- Date
- Time16 minutes
Step 1: Baseline CPU, RAM, and Disk
bash
sudo apt update
sudo apt install -y htop iotop sysstat
htop
iostat -xz 1 5Step 2: Verify CPU Frequency Governor
bash
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | sort | uniq
sudo apt install -y linux-tools-common linux-tools-generic
sudo cpupower frequency-set -g performanceStep 3: Configure Swappiness and Dirty Ratios
bash
sudo tee /etc/sysctl.d/99-game-tuning.conf >/dev/null <<'EOF'
vm.swappiness = 10
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
EOF
sudo sysctl --systemStep 4: Network Stack Tuning
bash
sudo tee -a /etc/sysctl.d/99-game-tuning.conf >/dev/null <<'EOF'
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 250000
net.ipv4.udp_rmem_min = 16384
net.ipv4.udp_wmem_min = 16384
net.ipv4.tcp_fin_timeout = 15
EOF
sudo sysctl --systemStep 5: Prioritize Process CPU Cores
Pin a game server process to dedicated cores for better scheduling consistency.
bash
taskset -c 2-5 ./start-server.shStep 6: Use Nice and Ionice
bash
nice -n -5 ionice -c2 -n0 ./start-server.shStep 7: Firewall and DDoS Surface Reduction
bash
sudo ufw default deny incoming
sudo ufw allow 25565/tcp
sudo ufw allow 25565/udp
sudo ufw statusStep 8: Continuous Monitoring
bash
sar -n DEV 1 20
sar -u 1 20
journalctl -u your-game-service -fStep 9: Example Java Flags (Minecraft)
bash
java -Xms4G -Xmx6G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=100 -XX:+AlwaysPreTouch -jar server.jar nogui"Stable frame and tick pacing is usually won through consistency, not by chasing peak benchmark numbers."



