Aikar's flags are a great way to optimize your Minecraft server's performance, and will allow you to squeeze out every last drop of performance from your CPU and RAM. In this article, we will discuss what Aikar's flags are, how they work, and how you can apply them to your server.

How to apply Aikar's Flags

Applying Aikar's flags is as simple as updating your Minecraft server's startup script to use the following Java flags:

java -Xms4096M -Xmx4096M -Dterminal.jline=false -Dterminal.ansi=true -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=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui

You will need to make a few simple modifications to the flags before you are ready to start your server. First, you will need to change the amount of RAM allocated to your server in the first two flags. In the example, we are allocating 4096MB of memory, but you may want to allocate more or less. We don't recommend allocating less than 2GB (2048MB) of memory to your server. We have an entire guide on choosing the right amount of memory for your Minecraft server that you can read if you want more information.

The second flag that you will need to modify is at the very end, where you will need to specify your server's jar file. In this example, we named the jar file server.jar, but you will need to update this to your server's jar file name, or rename your server's jar file to match server.jar.

Once you have applied these flags, you can start your server. Some hosting companies may not allow you to use Aikar's flags on your server. Pufferfish Host provides servers with Aikar's flags enabled by default, so your server is always as optimized as possible.

Special Considerations

If you are using Pterodactyl Panel (or otherwise running your server in a resource-limited environment), you will need to leave some room for overhead. If you limit your server to 16GB, then you will only want to allocate 12GB or 14GB in Aikar's flags. This is due to various overhead that the JVM incurs when running using Aikar's flags. The exact cause of this overhead is sometimes disputed but generally it can be attributed to native buffers, GC overhead, and in some rare cases, memory leaks. There is much fluctuation with the amount of overhead required, so if your server is crashing due to memory-related issues, you may need to allocate less memory in Aikar's flags. Pufferfish Host covers this overhead for you free-of-charge.

What are Aikar's Flags

Aikar's flags are an optimized set of flags that can increase your server's performance with little effort on your part. By default, Java's garbage collector is not optimized for running Minecraft servers, but Aikar's flags is a set of tuned flags that is specifically designed for running Minecraft servers. These flags will reduce your server's pause times due to garbage collection and will cause the JVM to avoid lengthy old-gen garbage collection cycles.

Additional Flags

If you are using the Pufferfish server software, you can add the additional flag --add-modules=jdk.incubator.vector to aikar's flags, anywhere before the -jar flag. This option will enable additional optimizations supported by the Pufferfish server software which rely on Java features which are still in beta. This is a great way to squeeze even more performance out of your Minecraft server.

Misconceptions

There are some common misconceptions around the usage of startup flags like Aikar's flags for Minecraft servers. First, using new flags like ZGC is not advisable. Performance on Aikar's flags is just fine with proper optimization, and switching to anything else is not likely to yield any improved performance results, and may even lead to decreased stability. Secondly, allocating too much memory can be detrimental to operating a server. We don't recommend ever allocating more than 16GB to a single Minecraft server, as this can cause the JVM's garbage collector to become congested. This can lead to increased GC pause times and will slow down your server. Only allocate as much memory as you need, your goal should be to allocate as little memory as possible.

Finishing Remarks

Aikar's flags are a great addition to any Minecraft server struggling with performance issues. If you have applied Aikar's flags (or if your host won't let you apply Aikar's flags) and your server is still having performance issues, consider switching to Pufferfish Host to upgrade your hardware. The greatest performance gains often come from simply using more capable hardware. If you are unable to switch hosting providers, you can consider switching to our custom server software, which we make available to the community free-of-charge.