Optimization
Tips and techniques for improving server performance with Magma
Optimizing Your Magma Server
Running a Minecraft server with both NeoForge mods and Bukkit plugins can be resource-intensive. This guide provides strategies and tips to optimize your Magma server for better performance.
Understanding Performance Bottlenecks
Minecraft servers typically face bottlenecks in these areas:
- CPU: Single-threaded performance is crucial for Minecraft
- RAM: Insufficient memory causes lag spikes and chunk loading issues
- Disk I/O: Slow storage affects world saving and chunk loading
- Network: High latency or packet loss causes rubber-banding and delays
JVM Optimization
Choosing the Right Java Version
For Magma servers running Minecraft 1.16+:
- Use Java 21 or newer for best performance
- Avoid outdated Java versions
Optimized JVM Flags
For servers with 4-8GB RAM allocation:
For servers with 8-16GB RAM allocation:
Key JVM Flags Explained
- -Xms/-Xmx: Minimum and maximum memory allocation
- -XX:+UseG1GC: Use the Garbage-First (G1) garbage collector
- -XX:MaxGCPauseMillis: Target pause time for garbage collection
- -XX:+AlwaysPreTouch: Pre-touch all memory pages to avoid lag spikes
Optimizing Server Configuration
server.properties
spigot.yml
bukkit.yml
Mod Management and Plugin Optimization
Reducing Mod Count
More mods = more resource usage. Consider:
- Removing unused mods
- Using all-in-one mods instead of multiple small mods
- Carefully selecting which mods to include
Performance-Enhancing Plugins
Add these plugins to improve performance:
- Clearlagg: Removes entities and limits mob spawning
- FastChunkPreGen: Pre-generates chunks to avoid lag during exploration
- Spark: Performance profiling to identify issues
- EntityTrackerFixer: Fixes entity tracking issues
Configuring Plugins for Performance
Common plugin optimizations:
- Reduce backup frequency
- Disable features you don't need
- Set reasonable limits for entities, hoppers, etc.
- Use lightweight alternatives for resource-heavy plugins
World Optimization
Pre-generating the World
Pre-generate your world to avoid lag when players explore:
World Border
Set a reasonable world border to prevent excessive exploration:
Chunk Loading Optimization
- Use a plugin like Chunky to pre-generate chunks
- Consider using a plugin with chunk loading management
Resource Monitoring
CPU Monitoring
Watch CPU usage to identify lag sources:
- Use plugins like Spark or Timings
- Check the console for TPS (Ticks Per Second)
Example with Spark:
Memory Monitoring
Monitor memory usage to prevent crashes:
- Watch for garbage collection (GC) frequency
- Check for memory leaks with plugins like Spark
Disk I/O Monitoring
Check disk activity:
- Move world files to an SSD if possible
- Reduce autosave frequency for less disk activity
Network Optimization
Reducing Network Load
- Set a reasonable
network-compression-threshold
(256 is good) - Use a plugin like ProtocolLib to optimize packet handling
- Consider a rate limiter for connections
Anti-DDoS Measures
- Consider a proxy like BungeeCord/Waterfall or Velocity
- Use plugins with anti-bot features
- Set up firewall rules to prevent attacks
Regular Maintenance
World Cleaning
Regularly clean up your world:
- Remove unused player data
- Delete old backup files
- Clear logs periodically
Chunk Reset
Reset infrequently visited chunks:
- Use plugins to detect and reset chunks with issues
- Clear unused chunks to reduce world size
Database Optimization
If using MySQL:
- Regularly optimize tables
- Set up proper indexing
- Schedule database maintenance
Advanced Techniques
Server Profiling
Use profiling tools to identify specific issues:
- Spark's profiling functionality
- Minecraft timings reports
- Aikar's timings system
Multi-server Setup
For larger communities, consider:
- Split your server into multiple specialized servers
- Use BungeeCord/Waterfall or Velocity to connect them
- Dedicate servers to specific tasks (lobby, survival, creative)
OS-Level Optimization
Optimize your operating system:
- Disable unnecessary services
- Prioritize Minecraft server process
- Use a server-focused Linux distro
Optimization Checklist
Before deploying your server:
- ✅ Set optimal JVM flags
- ✅ Configure server.properties, spigot.yml, and bukkit.yml
- ✅ Install performance-enhancing plugins
- ✅ Pre-generate your world
- ✅ Set up monitoring tools
- ✅ Implement backup solutions
- ✅ Test with varying player counts
- ✅ Create a maintenance schedule
Next Steps
After optimizing your server, you might want to:
- Learn about server wrappers for better management
- Explore advanced plugin configuration
- Check out troubleshooting for common issues