> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Optimise a Linux Server for Game Server Performance

> Optimise a Linux server for game server performance: check steal time and per-core load, raise priority with Nice=, reduce swapping and pin CPU cores.

To optimise a Linux server for a game server, first check per-core load with `mpstat -P ALL 5 1` and CPU steal (`st`) in `top`, because most game servers run their main loop on one core. Then give the game's systemd service `Nice=-5`, set `vm.swappiness=10`, raise `LimitNOFILE`, and run backups with `nice` and `ionice`. On dedicated servers, also pin cores and use the `performance` governor.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 30 minutes | Ubuntu, Debian, AlmaLinux, Rocky Linux with systemd | sudo access; your game server running as a [systemd service](https://help.freakhosting.com/portals/other/how-to-create-a-systemd-service.md) |

## Before you start

* [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md) as a user with `sudo`. Root users can leave out `sudo`.
* Change one thing at a time and measure again. Tuning can't make up for too little RAM or CPU, and the game's own settings (view distance, tick rate, plugins, mods) usually matter more than the operating system.
* Install `sysstat` for `mpstat` and `pidstat`: `sudo apt install sysstat` or `sudo dnf install sysstat`.

## How to find what is slowing your game server down

**1. Check per-core load**

```bash theme={null}
mpstat -P ALL 5 1
```

If one core sits near 100% `%usr` while the others idle, the game's main thread is the limit. More cores won't help; a faster core or lighter game settings will.

**2. Check steal time**

In `top`, look at `st` on the `%Cpu(s)` line, or `%steal` in `mpstat`. Steal is time your virtual CPU was ready but the host ran something else. Consistently high steal while your server is busy causes lag you can't fix inside the VPS.

**3. Check memory and swap**

```bash theme={null}
free -h
vmstat 5 5
```

Low **available** memory or non-zero `si`/`so` columns mean the game is being swapped out, which causes long freezes. See [check memory usage](https://help.freakhosting.com/portals/other/how-to-check-memory-usage-on-linux.md).

**4. Check disk waits**

`wa` above a few percent during lag spikes points to the disk, often world saves or backups. See [check disk I/O](https://help.freakhosting.com/portals/other/how-to-check-disk-io-performance-on-linux.md).

**5. Check the network path**

Lag that only some players see is usually the route between them and the server. See [diagnose network latency](https://help.freakhosting.com/portals/other/how-to-diagnose-network-latency-issues.md).

## How to give the game server priority

Use a systemd drop-in so the settings survive updates to the unit file. Replace `mygame` with your service name.

```bash theme={null}
sudo systemctl edit mygame.service
```

Add:

```ini theme={null}
[Service]
Nice=-5
LimitNOFILE=65536
```

Save, then apply:

```bash theme={null}
sudo systemctl restart mygame.service
systemctl show mygame.service -p Nice -p LimitNOFILE
```

| Setting | What it does |
| - | - |
| `Nice=-5` | Nice runs from `-20` (highest priority) to `19` (lowest). A negative value gives the game more CPU when other processes compete for it |
| `LimitNOFILE=65536` | Raises the open-file limit (files and network sockets). Busy servers with many players or plugins can hit the default. See [fix too many open files](https://help.freakhosting.com/portals/other/how-to-fix-too-many-open-files.md) |

Don't go lower than about `-10` and never use `-20` for a game: it can starve SSH and system services when the game misbehaves.

## How to stop the game server being swapped out

`vm.swappiness` (range `0` to `200`, default `60`) tells the kernel how readily to swap memory out compared with dropping file cache. A lower value keeps program memory in RAM longer.

```bash theme={null}
echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-gameserver.conf
sudo sysctl --system
sysctl vm.swappiness
```

Keep some swap anyway as a safety net against the out-of-memory killer; see [add swap space](https://help.freakhosting.com/portals/other/how-to-add-swap-space-on-linux.md). If the server swaps all the time, it needs more RAM or a lower memory setting in the game (for example a smaller Java `-Xmx`).

## How to keep backups and updates from causing lag

Run heavy jobs at the lowest CPU and disk priority, and schedule them when few players are online:

```bash theme={null}
nice -n 19 ionice -c3 tar -czf /backup/world-$(date +%F).tar.gz /home/alex/gameserver/world
```

`nice -n 19` gives the job the lowest CPU priority and `ionice -c3` the idle disk class. Put the command in [cron](https://help.freakhosting.com/portals/other/how-to-schedule-tasks-with-cron.md) at a quiet hour.

## How to pin game servers to CPU cores (dedicated servers)

When several game servers share one machine, pinning each to its own cores stops them competing for the same core.

```bash theme={null}
sudo systemctl edit mygame.service
```

```ini theme={null}
[Service]
CPUAffinity=2 3
```

This lets `mygame` run only on cores 2 and 3. Leave core 0 free for the system. Check the core numbers with `nproc` or `lscpu`. On a small VPS, pinning rarely helps, because your vCPUs are already shared by everything on the server.

## How to set the CPU governor (dedicated servers)

The CPU frequency governor decides how fast the cores run. `performance` asks for the highest frequency at all times.

```bash theme={null}
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors
echo performance | sudo tee /sys/devices/system/cpu/cpufreq/policy*/scaling_governor
```

The change lasts until the next reboot. If `/sys/devices/system/cpu/cpufreq` doesn't exist, which is normal on a VPS, the host controls the CPU frequency and there is nothing to change. With the `intel_pstate` driver, the file shows the driver's own algorithm (`performance` or `powersave`) rather than a classic governor.

> [!WARNING]
>
> The `performance` governor raises power use and heat. On a dedicated server that is usually fine, but keep an eye on temperatures if your hardware reports them.

## What about TCP tuning and BBR?

Most game servers send game traffic over UDP. TCP congestion control such as [BBR](https://help.freakhosting.com/portals/other/how-to-enable-bbr-tcp-congestion-control.md) affects TCP connections (web panels, downloads, some games' file transfers), not UDP game traffic. Change network sysctls only when your game's documentation asks for a specific value.

## How to check it worked

```bash theme={null}
ps -o pid,ni,psr,cmd -C java
pidstat -u 5 1
```

`NI` should show your nice value and `PSR` the core the process last ran on (inside your `CPUAffinity` list). Then compare the same in-game measure as before, for example tick time or TPS, at a similar player count.

## Frequently asked questions

### Will more CPU cores make my game server faster?

Only if the game uses them. Many game servers do most work on one main thread, so single-core speed matters more. `mpstat -P ALL` shows whether one core is maxed out.

### Should I disable swap completely?

No. Without swap, a memory spike lets the out-of-memory killer stop your game server. Keep a small swap file and lower `vm.swappiness` instead.

### Is a negative nice value safe?

Moderate values such as `-5` are. Very low values can starve SSH and system services if the game gets stuck in a loop, making the server hard to reach.

### Does the game panel do this for me?

This guide is for game servers you run yourself on a VPS or dedicated server, for example with [LinuxGSM](https://help.freakhosting.com/portals/other/how-to-host-game-servers-with-linuxgsm.md) or [Pterodactyl](https://help.freakhosting.com/portals/other/how-to-install-pterodactyl-panel-on-a-vps.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every server guide in one place.

> [card] [Host game servers with LinuxGSM](https://help.freakhosting.com/portals/other/how-to-host-game-servers-with-linuxgsm.md)
>
> Install and manage game servers.

> [card] [Run a Minecraft server](https://help.freakhosting.com/portals/other/how-to-run-a-minecraft-server-on-a-vps.md)
>
> Java memory and service setup.

> [card] [Limit CPU and memory](https://help.freakhosting.com/portals/other/how-to-limit-cpu-and-memory-for-a-process.md)
>
> Keep other programs in check.

> [card] [Diagnose network latency](https://help.freakhosting.com/portals/other/how-to-diagnose-network-latency-issues.md)
>
> Find where lag comes from.

> [card] [Find what is using CPU](https://help.freakhosting.com/portals/other/how-to-find-what-is-using-cpu-on-linux.md)
>
> Spot busy processes.

***

> [!NOTE]
>
> **Checked against the [systemd.exec(5)](https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html) manual and the Linux kernel documentation for [vm sysctls](https://docs.kernel.org/admin-guide/sysctl/vm.html) and [CPU frequency scaling](https://docs.kernel.org/admin-guide/pm/cpufreq.html)** on 4 November 2026; `mpstat`, `vmstat`, `ps` and `nice`/`ionice` commands tested on Ubuntu 24.04 LTS. The systemd and sysctl changes were not applied in our test environment. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.