7 Days To Die Linux Server

7 Days To Die Linux Server

Reading time1 min
#Gaming#Linux#Servers#7DaysToDie#DedicatedServer#GameServer

Optimizing 7 Days to Die Dedicated Server Performance on Linux

Deploying a 7 Days to Die server on Linux offers measurable gains in efficiency, control, and reliability over Windows-based hosts. Battle-hardened admins know: an untuned Linux box only goes so far before disk I/O stalls, Mono GC lags, or save corruption rears its head. Out-of-the-box defaults? They’re fine for hobbyists. For long-term stability and consistent client performance, a few key OS-level (and application-level) modifications make the difference.

Below: practical notes from the field, tested with vanilla 7DTD builds (Alpha 21) and Ubuntu 22.04 LTS.


Choosing Your Linux Foundation

  • Ubuntu Server LTS (20.04/22.04): Prioritize for widespread Mono compatibility and up-to-date security patches.
  • Debian Stable: Slightly slower update cadence, but rock-solid for unattended operation.
  • Rocky Linux/CentOS Stream: Viable if RHEL environments are standard in your stack.
  • Avoid ultra-minimal distros unless you’re keen on dependency hunting (e.g., Alpine’s musl/Mono issues).

Gotcha: Some “minimal” VPS images omit kernel modules (inotify, hugepages) your server may need at scale.


Dependency Installation (Mono, Screen, Tools)

7DTD’s dedicated server leverages the .NET/Mono stack. If Mono is missing or misconfigured, expect immediate startup failures:

sudo apt update
sudo apt install -y mono-complete screen wget
  • mono-complete (Mono 6.8+ required as of Alpha 21; check with mono --version).
  • screen: Detach and reattach to running sessions.
  • wget: Not strictly required, but practical for automated updates.

Error on startup? Typical sign of missing Mono libraries:

Error: assembly:/home/7dtd_server/7DaysToDieServer_Data/Managed/Assembly-CSharp.dll

Install missing dependencies or use ldd to troubleshoot.


Deploying Server Files with SteamCMD

Faster, reproducible provisioning uses SteamCMD:

mkdir -p ~/steamcmd && cd ~/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar xzf steamcmd_linux.tar.gz
./steamcmd.sh +login anonymous \
    +force_install_dir ~/7dtd_server/ \
    +app_update 294420 validate \
    +quit
  • app_update 294420 = 7DTD Dedicated Server (current as of 2024-06).
  • On update failure, check for SteamCMD errors like:
    ERROR! Failed to install app '294420' (No subscription)
    
    Usually, re-run as the same user that will operate the server.

OS-Level Optimizations

1. Raise Inotify Limits

7DTD’s world autosave is inotify-heavy. Default limits can bottleneck servers with busy save cycles or large world files.

Add to /etc/sysctl.d/99-7dtd.conf:

fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 512

Apply immediately:

sudo sysctl --system

2. Network Stack Tuning

High-traffic servers suffer from buffer underruns and packet drop; raise kernel TCP and buffer params:

net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_congestion_control = cubic
net.ipv4.tcp_mtu_probing = 1

Append to /etc/sysctl.d/99-7dtd-net.conf, then:

sudo sysctl --system

Trade-off: High buffer values increase memory footprint marginally on connection spikes.

3. CPU Governor Lock

Default governor settings can throttle performance during heavy player combat or world generation.

Force performance governor:

sudo apt install cpufrequtils
sudo cpufreq-set -g performance

Check applied policy:

cpufreq-info | grep "current policy"

4. Enable HugePages (Advanced)

For servers handling >16 players with large worlds, reducing memory management overhead yields visible GC improvements.

Configure hugepages (e.g., 128)

  • /etc/sysctl.d/99-7dtd-hugepages.conf:
    vm.nr_hugepages=128
    
  • Reload: sudo sysctl --system
  • Validate:
    grep Huge /proc/meminfo
    

Note: Too few hugepages → fallback, but too many → starvation for other processes.


Launching the Server (Screen + Custom Script)

A basic starting script (start_7dtd.sh):

#!/bin/bash
cd "$(dirname "$0")"

export MONO_THREADS_PER_CPU=50
export MONO_GC_PARAMS="nursery-size=128m"

screen -dmS 7dtd_server mono --server --gc=sgen --optimize=all \
  ./7DaysToDieServer.x86_64 \
  -configfile=serverconfig.xml -logfile output.log \
  -quit -batchmode +secureserver/MyServerID \
  +serverport 26900 +maxplayers 12 +crossplaymode None

echo "Started 7DTD server in detached screen '7dtd_server'"
  • MONO_THREADS_PER_CPU: 50 is a practical cap unless benchmarking says otherwise.
  • maxplayers: Set realistic to avoid resource starvation.

Make it executable: chmod +x start_7dtd.sh

Known issue: Mono logs TLS errors on some VPS networks; mostly harmless unless clients fail to connect.


Automatic Restart and Backup

1. Scheduled Save Backups

Basic backup via cron (every 6h):

0 */6 * * * tar czf ~/backups/7dtd_$(date +\%F_\%H-%M).tar.gz ~/7dtd_server/Saves/

Backup overhead negligible on SSDs; on spinning disks, monitor for I/O spikes.

2. Systemd - Self-Healing Server Process

/etc/systemd/system/7dtd.service

[Unit]
Description=7 Days to Die Dedicated Server
After=network.target

[Service]
User=gameuser
WorkingDirectory=/home/gameuser/7dtd_server/
ExecStart=/usr/bin/mono --server --gc=sgen --optimize=all ./7DaysToDieServer.x86_64 \
    -configfile=serverconfig.xml -logfile output.log \
    -quit -batchmode +secureserver/MyServerID +serverport 26900 +maxplayers 12 +crossplaymode None
Restart=always
RestartSec=10
Environment=MONO_THREADS_PER_CPU=50

[Install]
WantedBy=multi-user.target

Standard systemd idioms apply:

sudo systemctl daemon-reload
sudo systemctl enable --now 7dtd.service
sudo systemctl status 7dtd.service

Check for failure status reasons; Mono sometimes keeps partial processes as zombies after OOM kills.


Health Monitoring and Troubleshooting

  • htop, glances: Real-time CPU/memory saturation.
  • dstat, iotop: Catch disk bottlenecks during map generation or large save cycles.
  • Prometheus/Grafana: For production—expose Mono stats, kernel I/O, or network error counts.

Watch for:

  • STEAL time (cloud VPS): Sustained >2% indicates oversold VM, expect random lag spikes.
  • System log (/var/log/syslog): Watch for OOM kills, inotify exhaustion, or Mono unhandled exceptions.

Example inotify exhaustion:

inotify_add_watch: No space left on device

Bump sysctl settings if this appears under load.


Non-Obvious Pro Tips

  • SSD required for world-gen heavy servers; HDDs inevitably bottleneck world saves as regions expand.
  • Keep Mono version pinned if stability is a concern. Upstream Mono occasionally breaks backward compatibility.
  • Avoid root execution—run as gameuser, especially if leveraging systemd.
  • Use nice and ionice when running alongside database or file services:
    nice -n 10 ionice -c 2 -n 6 mono --server ...
    
  • For modded servers, separate test/prod environments. Many SDTD mods break save compatibility across versions.

Final Thoughts

Efficient Linux hosting for 7 Days to Die isn’t unattainable—just a series of small OS- and runtime-level adjustments. Monitor for the silent killers: disk latency, Mono GC stalls, kernel watcher limits. Most performance collapses occur when world size and player counts scale beyond “default” comfort.

Admins aiming for six-month uptimes and solid multiplayer experience will want to treat these notes as a working checklist. For public instances, ongoing monitoring and periodic kernel patching remain non-negotiable.

If it's running smoothly today, odds are you touched at least half the items above—and probably customized two or three for your workload. That’s the difference between “just works” and resilient service.