Back to Blog

How to Optimize a Minecraft Server

How to Optimize a Minecraft Server
Command of the Day
taskset -c 0,1 java -jar server.jar

What it does: Binds the Minecraft Java process to specific CPU cores (cores 0 and 1) to prevent CPU cache thrashing across sockets.

Running a smooth Minecraft server with 30+ concurrent players requires fine-tuning configuration parameters beyond default values. Out of the box, vanilla settings prioritize graphical distance and unconstrained mob mechanics over CPU efficiency.

In this guide, we provide a complete optimization blueprint for Paper and Purpur servers hosted on a RivinCloud VPS.


1. Step 1: Choose the Right Server Core

Replace the default Vanilla or Spigot JAR file with Paper or Purpur:

  • Vanilla: Unoptimized single-threaded server software.
  • Spigot: Introduces basic performance patches and plugin API.
  • Paper: Fixes memory leaks, optimizes entity tracking, multi-threads async tasks, and provides extensive tuning configs.
  • Purpur: Built on top of Paper with additional gameplay toggles and performance enhancements.

2. Step 2: Key Configuration File Tweaks

A. server.properties

view-distance=7
simulation-distance=4
network-compression-threshold=256

B. spigot.yml

world-settings:
  default:
    mob-spawn-range: 4
    entity-activation-range:
      animals: 16
      monsters: 24
      raiders: 32
      misc: 8
    merge-radius:
      item: 3.5
      exp: 4.0

C. paper-world.yml (or paper-global.yml)

chunks:
  auto-save-interval: 6000
  max-auto-save-chunks-per-tick: 24
environment:
  optimize-explosions: true
tick-rates:
  mob-spawner: 2
  container-update: 2

3. Step 3: JVM Garbage Collection Optimization

Use Aikar's flags when launching Java to prevent multi-second garbage collection pauses:

java -Xms6G -Xmx6G -XX:+UseG1GC -XX:+ParallelRefProcEnabled \
-XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions \
-XX:+DisableExplicitGC -XX:+AlwaysPreTouch \
-XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 \
-XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 \
-XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 \
-jar paper.jar --nogui

Command of the Day: taskset

The taskset utility sets or retrieves the CPU affinity of a running process, pinning it to specific CPU cores.

Syntax

taskset -c [core_ids] [command]

Practical Example

# Pin Java process to CPU Cores 0 and 1
taskset -c 0,1 java -Xms4G -Xmx4G -jar paper.jar --nogui

Explanation

Pinning a single-threaded Java application to dedicated physical cores prevents the OS scheduler from migrating the thread across different CPU cores, avoiding CPU L1/L2 cache misses and reducing latency.


Common Mistakes

  • Setting simulation-distance too high: Keeping simulation distance above 6 on crowded servers quickly causes MSPT spikes.
  • Using legacy CMS garbage collector: Avoid -XX:+UseConcMarkSweepGC on Java 17/21; use modern G1GC or ZGC.

Troubleshooting

  • Server lag during world saving: Increase auto-save-interval in Paper configuration from 6000 ticks to 12000 ticks, or use async world saving plugins.

Best Practices

  • Easily manage your server JARs, backups, and player sessions using RivinCloud's Nebula theme game panel interface featuring built-in Player Manager tools.
  • Periodically clear unused entities with clean plugin scheduling.

Frequently Asked Questions

Does disabling mob AI reduce lag?

Yes. Plugins that freeze non-essential entity AI during low TPS events save substantial main thread processing time.


Conclusion

Optimizing a Minecraft server involves a balance of Paper configuration adjustments, proper JVM garbage collection flags, and core affinity pinning with taskset. Keep your RivinCloud server running at peak performance!