We recently had some issues where our server was running super choppy, with only 2 people logged in at one time. The CPU usage would max out on the server, and eventually cause it to crash. After many hours of scouring Google and testing, I finally found the solution. I decided to share this information, in hopes that this information will help someone else from struggling.
My runtime command was missing quite a few Java runtime options. In the end, the options that optimized my server the most were: ‘–noconsole’, ‘-server’ and ‘nogui’.
Here is the command that is currently running our humble server:
/usr/bin/java -server -XX:ParallelGCThreads=2 -XX:+AggressiveOpts -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -Xmx1600M -Xms1600M -jar /home/minecraft/app/minecraft_server.1.11.2.jar nogui –noconsole
Next, I’ll break down what each directive of the command does.
- -server => to select the “server” VM. This increases performance drastically.
- nogui => Runs the Java Virtual Machine with no Graphical Interface. This increases performance drastically.
- –noconsole => Does not write output to the console. This increases performance drastically.
-XX:+AggressiveOpts =>Enables the use of aggressive performanceoptimization features.
- -XX:ParallelGCThreads=2 If we don’t explicitly set this flag, the JVM will use a default value which is computed based on the number of available (virtual) processors.
- -XX:+UseParNewGC => Enabels ParNew garbage collection. Garbage collector for the young generation.
- -XX:+UseConcMarkSweepGC =>Enables CMS garbage collection. Garbage collector for the old generation.
-XX:+UseParallelGC => Enables parallel thread usage in garbage collection.
- -Xms => Setting initial and minimum Java heap size
- -Xmx => set maximum Java heap size
If you’ve gone through all of these settings and still have bad performance, we would recommend increasing the size of your server. The bigger the world, the more resources a server will consume.
Have a great day!