تحسين خادم الألعاب: الأداء وتقليل التأخير
دليل تحسين أداء خادم الألعاب. إدارة CPU/RAM، إعدادات tick rate، ضبط الشبكة وتحسين النواة.
جدول المحتويات
Introduction
Game server performance is a critical factor that directly affects player experience. High latency, low tick rate, and insufficient resource management can cause players to leave your server. This guide covers CPU, RAM, network, and kernel-level optimizations for your game server on REXE VDS.
CPU Optimization
CPU Governor Setting
By default, Linux dynamically adjusts CPU frequency. For game servers, fixed high frequency is recommended:
# Check current governor
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# Switch to performance mode
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# Make persistent
sudo apt install cpufrequtils -y
echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
sudo systemctl restart cpufrequtils
CPU Affinity (taskset)
Bind your game server to specific CPU cores for better performance:
# Bind server to cores 0 and 1
taskset -c 0,1 ./server_binary
# Bind a running process
taskset -cp 0,1 $(pidof server_binary)
CPU Isolation
Isolate specific cores for the game server using kernel parameters:
sudo nano /etc/default/grub
# Add to GRUB_CMDLINE_LINUX_DEFAULT:
# isolcpus=2,3 nohz_full=2,3 rcu_nocbs=2,3
sudo update-grub
sudo reboot
RAM Optimization
Swap Settings
Minimize swap usage for game servers:
# Check current swappiness
cat /proc/sys/vm/swappiness
# Lower swappiness (default 60)
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
# Dirty page settings
echo 'vm.dirty_ratio=15' | sudo tee -a /etc/sysctl.conf
echo 'vm.dirty_background_ratio=5' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Huge Pages
Reduce TLB misses using huge pages:
# Set huge pages (2MB pages, 2048 count = 4GB)
echo 'vm.nr_hugepages=2048' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# Verify
cat /proc/meminfo | grep HugePages
OOM Killer Protection
Protect the game server process from OOM killer:
echo -17 > /proc/$(pidof server_binary)/oom_adj
Tick Rate Optimization
What is Tick Rate?
Tick rate determines how many times per second the server updates the game state. Higher tick rate provides smoother gameplay but requires more CPU and bandwidth.
| Game | Default Tick Rate | Recommended |
|---|---|---|
| CS2 | 64 | 128 |
| Minecraft | 20 | 20 |
| Rust | 30 | 30 |
| FiveM | 30 | 60 |
| V Rising | 30 | 30-60 |
Adjusting Tick Rate
# CS2 with 128 tick
./cs2 -dedicated -tickrate 128
# FiveM (server.cfg)
sv_maxclients 64
set sv_enforceGameBuild 3095
Network Optimization
Kernel Network Parameters
sudo nano /etc/sysctl.conf
# UDP Buffer sizes
net.core.rmem_max=26214400
net.core.wmem_max=26214400
net.core.rmem_default=1048576
net.core.wmem_default=1048576
# Network queue size
net.core.netdev_max_backlog=65536
net.core.somaxconn=65535
# TCP optimization
net.ipv4.tcp_rmem=4096 87380 26214400
net.ipv4.tcp_wmem=4096 65536 26214400
net.ipv4.tcp_max_syn_backlog=65536
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_fin_timeout=15
# UDP optimization
net.ipv4.udp_rmem_min=8192
net.ipv4.udp_wmem_min=8192
# Connection tracking
net.netfilter.nf_conntrack_max=1048576
sudo sysctl -p
Network Interface Optimization
# Increase ring buffer size
sudo ethtool -G eth0 rx 4096 tx 4096
# Interrupt coalescing
sudo ethtool -C eth0 rx-usecs 50 tx-usecs 50
Kernel Tuning
I/O Scheduler
Choose the appropriate I/O scheduler for game servers:
# Check current scheduler
cat /sys/block/sda/queue/scheduler
# For NVMe, none (noop) is recommended
echo none | sudo tee /sys/block/nvme0n1/queue/scheduler
# For SSD, mq-deadline is recommended
echo mq-deadline | sudo tee /sys/block/sda/queue/scheduler
File Descriptor Limits
sudo nano /etc/security/limits.conf
steam soft nofile 1000000
steam hard nofile 1000000
steam soft nproc 65535
steam hard nproc 65535
Monitoring Tools
Performance Monitoring
# CPU and RAM usage
htop
# Disk I/O monitoring
sudo iotop -o
# Network connections
ss -tuln
# Network traffic
sudo iftop -i eth0
# Detailed process monitoring
pidstat -p $(pidof server_binary) 1
Latency Testing
# Test server latency
ping -c 100 SERVER_IP
# Detailed path analysis with MTR
mtr --report SERVER_IP
Automatic Optimization Script
nano ~/optimize_gameserver.sh
#!/bin/bash
echo "=== Game Server Optimization ==="
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 2>/dev/null
sudo sysctl -w vm.swappiness=10
sudo sysctl -w net.core.rmem_max=26214400
sudo sysctl -w net.core.wmem_max=26214400
sudo sysctl -w net.core.netdev_max_backlog=65536
ulimit -n 1000000
echo "Optimization complete."
chmod +x ~/optimize_gameserver.sh
Conclusion
Game server optimization through CPU, RAM, network, and kernel-level improvements provides significant performance gains. With regular monitoring and proper configuration, you can deliver a low-latency, smooth gaming experience. REXE VDS high-performance hardware and Path.net DDoS protection ensure optimal server performance.
مقالات ذات صلة
كيفية تثبيت خادم FiveM: دليل خطوة بخطوة
دليل شامل لتثبيت خادم FiveM على REXE VDS: إعداد txAdmin، إعدادات المنافذ وتحسين الأداء لخوادم GTA V Roleplay. ابدأ خادمك في دقائق.
كيفية تثبيت خادم Minecraft: دليل Paper
دليل شامل لتثبيت خادم Paper/Spigot Minecraft على REXE VDS: إعدادات Java، إدارة الإضافات وتحسين الأداء للحصول على تجربة لعب مستقرة.
كيفية تثبيت خادم CS2: دليل شامل
دليل شامل لتثبيت خادم CS2 المخصص على REXE VDS: SteamCMD، رمز GSLT، إعداد الخادم، أوضاع اللعب وحماية DDoS عبر Path Panel.