Server lag is the enemy of every Minecraft server owner. In this comprehensive guide, we'll cover everything you need to know to optimize your server for peak performance, whether you're running a small SMP or a large network.
Understanding Server Performance
Before we dive into optimizations, let's understand the key metrics:
- TPS (Ticks Per Second): Ideal is 20.0. Below 18 indicates lag.
- MSPT (Milliseconds Per Tick): Should be under 50ms
- Memory Usage: Keep below 80% of allocated RAM
1. JVM Optimization
Your Java Virtual Machine settings have a massive impact on performance.
Aikar's Flags (Recommended)
These flags are optimized for Minecraft servers:
java -Xms10G -Xmx10G -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 -jar paper.jar --nogui
Memory Allocation
- Small servers (1-20 players): 4-6GB RAM
- Medium servers (20-50 players): 6-10GB RAM
- Large servers (50+ players): 10-16GB+ RAM
Important
Never allocate more than 12GB to a single server instance. For larger needs, use proxy networks (BungeeCord/Velocity).
2. Server Configuration
server.properties
view-distance=8
simulation-distance=6
network-compression-threshold=256
max-tick-time=60000
spigot.yml
settings:
save-user-cache-on-stop-only: true
world-settings:
default:
mob-spawn-range: 6
entity-activation-range:
animals: 16
monsters: 24
misc: 8
merge-radius:
item: 4.0
exp: 6.0
paper-world-defaults.yml
chunks:
max-auto-save-chunks-per-tick: 8
prevent-moving-into-unloaded-chunks: true
entities:
armor-stands:
tick: false
spawning:
despawn-ranges:
ambient:
hard: 72
soft: 30
3. Plugin Optimization
Plugins are often the biggest source of lag.
Identify Lag Sources
- Use /timings (Paper) or Spark profiler
- Check for plugins with high tick times
- Remove or replace poorly coded plugins
Plugin Best Practices
- Use async plugins when possible
- Avoid plugins that scan chunks frequently
- Limit logging plugins to essential data
- Use lightweight alternatives for heavy plugins
4. World Optimization
Pre-generate Your World
Chunk generation is extremely expensive. Use Chunky to pre-generate:
/chunky radius 5000
/chunky start
Limit World Size
Use a world border to prevent infinite world expansion:
/worldborder set 10000
Regular Maintenance
- Clear unused chunks with plugins like ChunkPurge
- Remove excessive entities in unloaded areas
- Optimize world files with Region Fixer
5. Entity Management
Entities are one of the biggest performance drains:
Mob Limits
- Limit mobs per chunk (bukkit.yml)
- Reduce spawn rates in low-activity areas
- Use mob stacking plugins for farms
Item Management
- Reduce item despawn time
- Merge nearby items
- Use hoppers sparingly (they're expensive!)
6. Network Optimization
For Self-Hosted Servers
- Use a dedicated connection
- Enable TCP optimization
- Consider using TCPShield for DDoS protection
Compression Settings
Adjust network-compression-threshold based on your situation:
- -1: Disabled (for proxy servers)
- 256: Good balance for most servers
- 512: For servers with bandwidth concerns
Monitoring Your Server
Regular monitoring helps catch issues before they become problems:
- Spark: Real-time profiling
- Plan: Player analytics and server stats
- Console logs: Watch for error patterns
Need More Players?
Once your server is optimized, list it on MC-Finder to attract players!
Add Your Server