You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

如何配置Linux主机仅使用12个物理核心运行游戏服务器?

Optimizing Your X5650 Linux Server for Game Hosting

Hey Alex, let's tackle this for your game server setup. First, a quick hardware recap: your two X5650 CPUs deliver 12 physical cores (6 per socket) and 24 logical cores (via Hyper-Threading, 2 per physical core). Since game servers often rely heavily on single-core performance, we’ve got two tailored solutions to match your request:

Option 1: Disable Hyper-Threading to Use Only 12 Physical Cores

If your game is primarily single-threaded, Hyper-Threading can sometimes hurt performance by sharing physical core resources (like L1/L2 cache). Disabling it will let you use just the 12 physical cores, which is ideal for single-core-focused workloads.

  • Temporary fix (resets on reboot)
    First, confirm your core topology with lscpu:

    lscpu | grep -E 'Core\(s\) per socket|Socket\(s\)|Thread\(s\) per core'
    

    You’ll see Thread(s) per core: 2 for your X5650s. Next, map logical cores to physical ones:

    for i in $(seq 0 23); do
      echo "Logical CPU $i → Physical Core $(cat /sys/devices/system/cpu/cpu$i/topology/core_id), Socket $(cat /sys/devices/system/cpu/cpu$i/topology/physical_package_id)"
    done
    

    Each physical core will have two logical cores (e.g., physical core 0 maps to logical 0 and 1). To disable the hyper-threaded logical cores, run:

    # Example: Disable every odd-numbered logical core (adjust if your mapping differs)
    for cpu in $(seq 1 2 23); do
      echo 0 > /sys/devices/system/cpu/cpu$cpu/online
    done
    
  • Permanent fix (best practice)
    The most reliable way is to disable Hyper-Threading directly in your server’s BIOS. Look for an option labeled "Hyper-Threading Technology" or similar, set it to Disabled, save changes, and reboot. Your system will now only recognize and use the 12 physical cores.

Option 2: Keep Hyper-Threading, but Bind Game Server to Physical Core Pairs

If your game can leverage multi-threading, you can keep Hyper-Threading enabled but ensure your game server uses both logical cores tied to each physical core, while isolating these cores from other system processes.

  • Step 1: Identify core pairs
    Use the same mapping command from Option 1 to note which logical cores belong to each physical core. For example:

    Logical CPU 0 → Physical Core 0, Socket 0
    Logical CPU 1 → Physical Core 0, Socket 0
    Logical CPU 2 → Physical Core 1, Socket 0
    ...

  • Step 2: Bind your game server to specific cores
    Use the taskset command to launch your game server with core affinity. For single-core performance focus, bind to one logical core per physical core:

    # Bind to the first logical core of each physical core (12 total)
    taskset -c 0,2,4,6,8,10,12,14,16,18,20,22 ./your_game_server_executable
    

    If you want to use all 24 logical cores (utilizing Hyper-Threading), use:

    taskset -c 0-23 ./your_game_server_executable
    

    If you’re managing the game server via systemd, edit its service file (e.g., /etc/systemd/system/game-server.service) to set persistent core affinity:

    [Service]
    CPUAffinity=0,2,4,6,8,10,12,14,16,18,20,22
    ExecStart=/path/to/your_game_server_executable
    

    Then reload systemd and restart the service:

    systemctl daemon-reload
    systemctl restart game-server.service
    

Extra Optimizations for Game Servers

To further boost performance for latency-sensitive games:

  • Add kernel parameters to reduce scheduling overhead. Edit /etc/default/grub and update the GRUB_CMDLINE_LINUX line:
    GRUB_CMDLINE_LINUX="... nohz_full=0-11 rcu_nocbs=0-11"
    
    Replace 0-11 with the range of logical cores you’re using (e.g., 0-23 if using all cores). Then update GRUB:
    # Debian/Ubuntu
    update-grub
    # CentOS/RHEL
    grub2-mkconfig -o /boot/grub2/grub.cfg
    
  • Disable unnecessary system services to free up CPU resources for your game server.

内容的提问来源于stack exchange,提问作者Alex Ulmer

火山引擎 最新活动