Running a smooth Minecraft server with 20+ players requires careful Java Virtual Machine (JVM) tuning and server configuration. Default Paper or Spigot settings tick too many entities and waste RAM on unoptimized Garbage Collection.
Recommended Aikar JVM Startup Flags
Copy these optimized G1GC flags into your server start script (adjust RAM to match your server, e.g., 6G - 10G):
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=15 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 --add-modules=jdk.incubator.vector -jar paper.jar nogui
Paper.yml Key Optimization Settings
max-auto-save-chunks-per-tick: Set to6(reduces disk I/O lag).despawn-ranges.soft: Set to28/hard: Set to96.entity-activation-range: Reduce tick ranges for passive animals and villager pathfinding.
Generate custom Windows (.bat) and Linux (.sh) start scripts with tuned flags using our Server Start Script Generator!
Profile before changing configuration
- Reproduce the lag with the normal player load.
- Run Paper's bundled Spark profiler while the issue is active.
- Identify whether time is spent in a plugin, entities, chunk generation, block entities or garbage collection.
- Change one relevant setting and capture another report under the same workload.
JVM flags are not a universal lag fix
Garbage-collector flags can improve pause behavior, but they cannot repair a plugin that blocks the main thread or a farm that creates excessive entities. Allocate enough memory for the workload without assigning all system RAM, keep Java at the version required by the server release and monitor actual heap use.
Avoid copying large optimization configuration files from unrelated servers. Paper defaults change, and reducing simulation or activation ranges can alter gameplay. Keep a backup, document every change and revert settings that do not produce a measurable improvement.
