How to use Aikar Flags for better Minecraft server performance

Aikar Flags can drastically improve the performance of a Minecraft server (Image via DEV community)
Aikar Flags can drastically improve the performance of a Minecraft server (Image via DEV community)

Minecraft servers are one of the most popular ways in which multiplayer is enjoyed. Through the use of a server, players from all over the world can connect and play with each other.

However, as more and more people join a server, the load begins to increase, and slowdowns may occur in the form of server lag and pauses. One of the best ways to mitigate this is by fine-tuning the server so that performance can be improved.

This article will specifically explain how to install Aikar's garbage collection flags for improved server performance.


Aikar Java Flags for Minecraft server performance: How to install them

Why should players use Aikar Flags for a Minecraft server?

The developers of Paper, which is currently the most popular brand of Minecraft servers, recommend that all server owners use Aikar Flags. These flags have been fine-tuned over the years with lots of data to give server owners the optimal experience.

In technical terms, these flags help speed up garbage collection, which is an essential process for all Java-based applications to function smoothly. Without garbage collection, the server would run out of RAM and would experience an out-of-memory error and crash. However, garbage collection itself can slow a server down if it's using the wrong parameters, which is where Aikar Flags come into play.

How to use Aikar Flags?

Using Aikar Flags is relatively simple and only requires a few adjustments depending on what brand of server is in use and how much memory (RAM) is allocated to the server instance.

For those using Paper with under 12 GB RAM, they can use the following flags for their server:

java -Xms<RAM AMOUNT>G -Xmx<RAM AMOUNT>G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15 -XX:InitiatingHeapOccupancyPercent=20 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar <JAR NAME>.jar nogui

For those using Paper with over 12 GB RAM, they can use the following flags for their server:

java -Xmx<RAM AMOUNT>G -Xmx<RAM AMOUNT>G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15 -XX:InitiatingHeapOccupancyPercent=20 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar <JAR NAME>.jar nogui

To check if the flags are correctly working, server admins using a dedicated server can simply check the running processes with the command "htop." If all has been performed correctly, a process using the same defined flags will be clearly visible.