All Guides

Optimize Minecraft Server 2026: Aikar Flags, RAM & TPS Guide

Fix Minecraft server lag: JVM flags, garbage collection tuning, world pre-generation. Step-by-step guide for 20 TPS.

Dirk Hesse
February 5, 2026
6 min read

Your Minecraft server lags despite having enough RAM? The problem is almost never the memory – it's the Java configuration.

In this guide, we'll show you the most important performance optimizations: From the legendary Aikar Flags to world pre-generation with Chunky.

Found a server, but which VPS?

Use our comparison to find the perfect VPS for your player count.

Compare VPS Servers

Why Java Flags Matter

Minecraft runs on the Java Virtual Machine (JVM). Without tuning, Java regularly pauses for "Garbage Collection" – cleaning up unused data in memory.

You feel these pauses as lag spikes, even though TPS shows 20. The server freezes briefly, players rubber-band, and redstone circuits break.

Note: Default Java settings are optimized for desktop applications, not game servers with constant memory throughput.


Aikar Flags: The Gold Standard

The Aikar Flags are a collection of JVM parameters specifically developed for Minecraft servers. They optimize the G1 Garbage Collector for minimal pauses.

Here are the complete flags for servers with 8-12GB RAM:

java -Xms8G -Xmx8G \
  -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 \
  -jar server.jar nogui

Important: Set -Xms and -Xmx to the same value! Different values lead to constant heap resizing and more lag.

What Do the Key Flags Do?

The following table explains the most critical parameters:

FlagFunctionWhy It Matters
-Xms / -XmxMin/Max heap sizeSame values prevent resizing
-XX:+UseG1GCGarbage collector typeG1 is optimal for Minecraft
-XX:+AlwaysPreTouchReserve RAM at startupPrevents lag on first chunk load
-XX:MaxGCPauseMillis=200Max pause timeKeeps GC pauses under 200ms

GenZGC: For Large Modpacks (12GB+)

Starting with Java 21, there's Generational ZGC – a garbage collector that reduces pause times to under 1ms. Ideal for heavy modded servers with 12-32GB RAM.

java -Xms16G -Xmx16G \
  -XX:+UseZGC \
  -XX:+ZGenerational \
  -XX:+AlwaysPreTouch \
  -XX:+DisableExplicitGC \
  -jar server.jar nogui

Tip: GenZGC requires slightly more CPU baseline load but virtually eliminates all GC lag spikes. Perfect for ATM9, Create, or other RAM-hungry modpacks.


Which Java Version?

The right Java version is crucial for performance and compatibility. Here's an overview:

Minecraft VersionJava VersionNote
1.17 - 1.17.1Java 16+Minimum
1.18 - 1.20.4Java 17LTS, recommended
1.20.5+Java 21Required, new features
1.21+Java 21 (or 23)Java 23 experimental

Tip: Always use the LTS version (17 or 21). Java 23 brings performance improvements but isn't officially supported by Forge yet.


Pre-Generate World with Chunky

The biggest lag source: Generating new chunks while players explore. Every new chunk means complex terrain calculation in real-time.

The solution: Generate the world before players join with the Chunky plugin.

/chunky radius 5000
/chunky start
# Wait until complete (can take hours)
/chunky confirm

How Long Does It Take?

Generation time depends on radius and CPU:

RadiusWorld SizeGeneration Time
5,000 blocks~4GB2-4 hours
10,000 blocks~17GB12-24 hours

Note: After pre-generation, the server only needs to load chunks from SSD – instead of calculating them live. This saves 50-80% CPU load during gameplay.


View Distance vs. Simulation Distance

View distance determines how many chunks are loaded per player. The formula: (2d + 1)² chunks per player.

This means: Small changes have massive impact:

View DistanceChunks per PlayerAssessment
6169Minimal, but playable
8289Standard for budget servers
10441Vanilla default
12625Only for powerful CPUs
161089Not recommended for MP

Pro tip: Set view-distance to 10 (visuals), but simulation-distance to 5 (calculations). Players see far, but mobs and redstone are only calculated nearby. Saves 50%+ CPU!


Quick Optimizations (5 Minutes)

These changes in server.properties and spigot.yml bring immediate performance gains:

SettingEffect
view-distance=830% less chunk loading
simulation-distance=550% less entity ticking
network-compression-threshold=256Less network overhead
max-tick-time=-1Prevents watchdog crashes during lag

Frequently Asked Questions

Conclusion

The most important optimizations at a glance:

  1. Use Aikar Flags – for servers up to 12GB RAM
  2. Enable GenZGC – for modpacks with 12GB+ RAM
  3. Pre-generate world – shift CPU load with Chunky
  4. Separate View/Simulation Distance – high visuals, low calculations

Found a server, but which VPS?

Use our comparison to find the perfect VPS for your player count.

Compare VPS Servers

Related Articles