How to Optimize Minecraft Server Performance & Reduce Lag

    Server Owners31 viewsUpdated 4 months ago

    Understanding Server Performance

    Minecraft servers run at 20 ticks per second (TPS). When TPS drops below 20, players experience lag — delayed block breaks, rubber-banding, and slow interactions. Here's how to keep your server running smoothly.

    Measuring Performance

    TPS (Ticks Per Second)

    • 20 TPS = Perfect, no lag
    • 18-19 TPS = Slight lag, barely noticeable
    • 15-17 TPS = Players will notice delayed actions
    • Below 15 = Significant lag, needs immediate attention

    Check TPS with: /tps (Paper/Spigot built-in)

    Spark Profiler

    Install the Spark plugin to identify exactly what's causing lag:

    1. 1Run /spark profiler start
    2. 2Wait 2-5 minutes during normal gameplay
    3. 3Run /spark profiler stop
    4. 4Analyze the generated flame graph

    Paper/Purpur Configuration

    paper-world-defaults.yml

    chunks:
      max-auto-save-chunks-per-tick: 8  # Lower for less IO lag
      
    entities:
      behavior:
        pillager-patrols:
          spawn-chance: 0.02  # Lower than default to reduce entity count
      spawning:
        per-player-mob-spawns: true  # Critical for multiplayer performance
        
    environment:
      optimize-explosions: true
      treasure-maps:
        enabled: false  # Prevents massive chunk loading searches

    spigot.yml

    world-settings:
      default:
        entity-activation-range:
          animals: 16  # Default is 32
          monsters: 24  # Default is 32
          raiders: 48
          misc: 8
        merge-radius:
          item: 4.0
          exp: 6.0
        mob-spawn-range: 6  # Default is 8

    Memory Management

    JVM Flags

    Use optimized startup flags:

    java -Xms4G -Xmx4G -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:G1RSScanBlockDrainThreshold=1 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -jar paper.jar --nogui

    Memory Rules

    • Xms = Xmx — Set minimum and maximum heap to the same value
    • Don't over-allocate — More RAM doesn't always mean better performance. 4-8GB is plenty for most servers
    • Leave 1-2GB for the OS — If your VPS has 8GB, allocate 6GB to Minecraft

    Entity Management

    Entity Limits

    Entities (mobs, items, dropped items, armor stands) are the #1 cause of lag.

    • Set view-distance to 8 or lower
    • Enable per-player-mob-spawns in Paper
    • Use plugins like ClearLagg to remove excess entities
    • Limit mob farm efficiency with spawning range adjustments
    • Cap entities per chunk: use WorldGuard flags or Farm Limiter plugins

    Hopper Optimization

    Hoppers cause significant lag on busy servers:

    # paper-world-defaults.yml
    hopper:
      cooldown-when-full: true
      disable-move-event: true  # Major performance improvement

    Chunk Management

    Pre-Generate Chunks

    Use Chunky to pre-generate your world before opening:

    /chunky radius 5000
    /chunky start

    Pre-generated chunks load instantly instead of causing lag spikes during exploration.

    World Borders

    Set reasonable world borders to prevent infinite exploration:

    • Survival: 10,000-20,000 block radius
    • Skyblock/Creative: As small as needed
    • Factions: 5,000-10,000 block radius

    Plugin Audit

    Finding Laggy Plugins

    1. 1Run /spark profiler during peak hours
    2. 2Check which plugins consume the most tick time
    3. 3Look for plugins making async operations synchronously
    4. 4Test by temporarily disabling suspected plugins

    Common Plugin Performance Issues

    • Poorly written economy plugins — Frequent database calls on the main thread
    • Scoreboard plugins — Updating every tick instead of every second
    • Hologram plugins — Too many holograms with frequent updates
    • Teleportation plugins — Loading chunks synchronously for /tpa

    Quick Wins Checklist

    1. 1✅ Use Paper or Purpur (not vanilla or Spigot)
    2. 2✅ Set view-distance to 8 and simulation-distance to 6
    3. 3✅ Enable per-player-mob-spawns
    4. 4✅ Pre-generate chunks with Chunky
    5. 5✅ Use optimized JVM flags
    6. 6✅ Install Spark for profiling
    7. 7✅ Set entity activation ranges lower
    8. 8✅ Disable treasure maps in Paper config
    9. 9✅ Set Xms equal to Xmx
    10. 10✅ Audit plugins with Spark profiler