Running a Minecraft server can be resource-intensive, especially with multiple players and plugins. This comprehensive guide will show you how to optimize your server for better performance and reduced lag.
Understanding Server Performance
Before diving into optimization, it's important to understand what affects your Minecraft server's performance. The main factors include:
- CPU Performance: Minecraft is primarily single-threaded, so CPU clock speed matters more than core count
- RAM Allocation: Too little or too much RAM can both cause issues
- World Size: Larger worlds with more chunks loaded require more resources
- Plugins/Mods: Each plugin adds overhead to your server
- Player Count: More players means more entities and calculations
1. Choose the Right Server Software
The server software you use can significantly impact performance:
Paper MC (Recommended)
Paper is a high-performance fork of Spigot that includes many optimizations out of the box. It's compatible with Spigot plugins and offers better performance with minimal configuration.
# Download Paper
wget https://papermc.io/api/v2/projects/paper/versions/1.20.4/builds/latest/downloads/paper-1.20.4.jar
# Run Paper
java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -jar paper-1.20.4.jar nogui
Purpur
Purpur is a fork of Paper with even more configuration options and optimizations. It's ideal for advanced users who want fine-grained control.
2. Optimize JVM Flags
Using the right Java Virtual Machine (JVM) flags can dramatically improve performance. Here's a recommended startup script:
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 -Dusing.aikars.flags=https://mcflags.emc.gs \
-Daikars.new.flags=true -jar server.jar nogui
Key Points:
-Xmsand-Xmxshould be the same value (your allocated RAM)- Use G1GC garbage collector for better performance
- These are known as "Aikar's Flags" - highly optimized for Minecraft
3. Configure server.properties
Optimize your server.properties file with these settings:
# Performance-focused server.properties
view-distance=6
simulation-distance=4
network-compression-threshold=256
max-tick-time=60000
spawn-protection=0
entity-broadcast-range-percentage=80
Explanation:
- view-distance: Lower values reduce chunk loading (6-8 is optimal for most servers)
- simulation-distance: Limits how far away entities are processed
- network-compression-threshold: Compresses packets larger than this size
- entity-broadcast-range-percentage: Reduces entity tracking distance
4. Optimize Paper Configuration
Paper includes additional configuration files that allow for deeper optimization. Edit paper-world-defaults.yml:
chunks:
auto-save-interval: 6000
prevent-moving-into-unloaded-chunks: true
entities:
spawning:
mob-spawn-range: 4
alt-item-despawn-rate:
enabled: true
anti-xray:
enabled: true
engine-mode: 2
5. Manage Plugins Wisely
Plugins can significantly impact performance. Follow these best practices:
Essential Performance Plugins:
- Spark: Performance profiler to identify lag sources
- ClearLagg: Removes entities and items automatically
- FarmControl: Limits farm sizes and automatic farms
- ChunkBuster: Efficiently removes large areas
Avoid Unnecessary Plugins:
- Remove plugins you're not actively using
- Avoid running multiple plugins that do similar things
- Use lightweight alternatives when possible
- Regularly update plugins to get performance improvements
6. World Management
Large worlds can cause performance issues. Consider these strategies:
Pre-generate Your World:
Use a plugin like Chunky to pre-generate chunks before players explore:
/chunky world world
/chunky radius 5000
/chunky start
World Borders:
Set world borders to limit world size and reduce chunk generation lag:
/worldborder center 0 0
/worldborder set 10000
7. Monitor Performance
Regular monitoring helps you identify and fix performance issues:
Using Timings:
/timings on
# Wait 5-10 minutes during typical server load
/timings paste
This generates a report showing what's consuming server resources.
Using Spark:
/spark profiler start
# Wait for profiling period
/spark profiler stop
8. Hardware Considerations
If you've optimized everything else, consider hardware upgrades:
- CPU: High single-thread performance is crucial (Intel i7/i9 or AMD Ryzen 5/7)
- RAM: 8GB minimum for vanilla, 12-16GB for modded servers
- Storage: NVMe SSDs provide much faster chunk loading than HDDs
- Network: 1Gbps connection recommended for larger servers
Conclusion
Optimizing a Minecraft server is an ongoing process. Start with the basics (server software, JVM flags, server.properties), then fine-tune based on your specific needs. Regular monitoring will help you identify issues before they become problems.
Remember that every server is different. What works perfectly for a 10-player vanilla server might not work for a 100-player modded server. Test changes gradually and monitor their impact.
Need Professional Hosting?
Our optimized Minecraft hosting plans come pre-configured with all these optimizations. Check out our Minecraft hosting plans starting at just $3/month.