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

# Minecraft Server Optimization

> Improve your Minecraft server performance by reducing lag and optimizing resources.

Lag is the number one enemy of every Minecraft server. Whether you have a small VPS or a dedicated server, proper optimization is fundamental. Here is how to do it.

### **1. Choose the Right Software**

Never use the vanilla `server.jar` file provided by Mojang for public servers. It is poorly optimized.

* **PaperMC**: The standard for performance and stability.
* **Purpur**: Based on Paper, offers even more configuration options and performance.
* **Folia**: For huge servers with real multithreading (requires specific configurations).

### **2. Startup Arguments (Aikar's Flags)**

Java Garbage Collection can cause freezes if not configured well. Use the famous "Aikar's Flags" in your startup script.

Replace your startup command with this (adjust RAM, e.g. 6G):

```bash theme={null}
java -Xms6G -Xmx6G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
```

### **3. File Configuration**

#### **server.properties**

* `view-distance`: Set between **6** and **8**. Higher values (10+) consume exponentially more resources.
* `simulation-distance`: Set between **4** and **6**. This controls how far mobs and redstone are active.
* `network-compression-threshold`: Set to **256**.

#### **bukkit.yml**

* `spawn-limits`: Reduce values (e.g., monsters: 50, animals: 10, water-animals: 5).
* `ticks-per.monster-spawns`: Increase to **10** or more (spawns mobs less frequently).

#### **spigot.yml**

* `merge-radius`: Increase values for item and exp (e.g., item: 4.0, exp: 6.0).
* `entity-activation-range`: Reduce slightly (e.g., animals: 16, monsters: 24).

#### **paper-world-defaults.yml (or paper.yml)**

* `max-auto-save-chunks-per-tick`: Set to **8** or less.
* `optimize-explosions`: Set to `true`.
* `mob-spawner-tick-rate`: Set to **2**.
* `container-update-tick-rate`: Set to **3**.

### **4. World Pre-generation**

Generating new chunks while players explore is the main cause of lag.

1. Install the plugin **Chunky**.
2. Set a radius (e.g., `/chunky radius 5000`).
3. Start generation: `/chunky start`.
4. Wait for completion (can take hours, do it before opening!).

<Note>
  Guide created by HighMark - All information and contacts on my [official website: Highmark.it](https://highmark.it)
</Note>
