Optimizing Minecraft Server Performance

TPS optimization, Aikar's flags, view-distance and simulation-distance tuning for a lag-free Minecraft server.

Understanding TPS

Minecraft servers run on a game loop that ticks 20 times per second (20 TPS). Each tick, the server processes entity movement, redstone, mob AI, chunk loading, and player actions. When the server cannot complete all work within a 50ms tick window, TPS drops below 20.

TPSExperience
20.0Perfect, no lag
18-20Minor delays, mostly unnoticeable
15-18Noticeable lag, delayed mob interactions
10-15Significant lag, blocks reappear after mining
Below 10Severe lag, rubber-banding, nearly unplayable

You can check TPS in-game with the /spark tps command (requires Spark plugin) or through the RespawnHost panel console.

JVM Flags and Memory Tuning

Aikar’s Flags

Aikar’s flags are the standard JVM tuning parameters for Minecraft servers. They optimize the G1 garbage collector to minimize pause times. Paper applies these by default, but if you are running Vanilla or Forge, you should add them manually:

java -Xms6G -Xmx6G \
  -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 server.jar nogui

Key principles:

  • Set -Xms and -Xmx to the same value to prevent heap resizing
  • Adjust total allocation based on your server’s needs (see RAM Requirements)
  • The G1HeapRegionSize should scale with total memory (8M for 6-10 GB, 16M for 12+ GB)

View Distance vs Simulation Distance

Since Minecraft 1.18, view distance and simulation distance are separate settings. This is one of the most effective optimizations available.

# server.properties

# What players can see (rendering only)
view-distance=10

# Where entities and redstone are ticked (server load)
simulation-distance=6
Player CountView DistanceSimulation Distance
1-1010-124-6
11-308-104-6
31-606-84
60+4-64

Simulation distance has a much larger impact on performance than view distance. Reducing simulation distance from 8 to 4 can improve TPS by 30-50% on busy servers.

Pre-Generating Chunks with Chunky

Chunk generation is one of the heaviest operations a Minecraft server performs. When players explore new terrain, the server must generate chunks in real time, causing significant lag.

Chunky pre-generates world terrain so players always walk through already-generated chunks:

# In-game or console commands
/chunky world overworld
/chunky center 0 0
/chunky radius 5000
/chunky start

This generates a 10,000 x 10,000 block area centered on spawn. Pre-generation runs in the background and you can monitor progress with /chunky progress.

Recommended pre-generation radii:

WorldRadiusArea
Overworld5000-10000 blocksCore play area
Nether2000-4000 blocksNether hub coverage
End1000-2000 blocksEnd cities and main island

Pre-generation takes time (hours for large radii) but is a one-time operation that permanently reduces server load.

Profiling with Spark

Spark is the standard profiling tool for Minecraft servers. It identifies exactly what is consuming your server’s tick time.

Installation

  1. Download Spark from Modrinth or Hangar
  2. Place the .jar in your /plugins folder (Paper) or /mods folder (Fabric)
  3. Restart the server

Key Commands

/spark profiler start       # Start CPU profiling
/spark profiler stop        # Stop and generate report
/spark profiler --timeout 60  # Profile for 60 seconds then auto-stop
/spark tps                  # Show current TPS
/spark tickinfo             # Show tick time breakdown

Spark generates a web link with a detailed breakdown showing:

  • Which methods consume the most CPU time
  • Which plugins or mods are causing lag
  • Thread distribution and GC impact

Focus your optimization efforts on the top items in the Spark report.

Entity and Mob Management

Entities are one of the largest performance drains. Each entity requires position tracking, AI processing, and collision checks.

Paper Entity Limits

Paper provides built-in entity limits in paper-global.yml:

entity_limits:
  max-entity-cramming: 8
  non-player-entity-spawn-rate: 4
  creature-spawn-range: 4

chunks:
  entity-per-chunk-save-limit:
    area_effect_cloud: 8
    arrow: 16
    breeze_wind_charge: 8
    ender_pearl: 8
    experience_orb: 16
    firework_rocket: 8
    hanging: 16
    item: 20
    item_frame: 8
    lightning: 2
    living: 20
    oak_boat: 1
    painting: 4
    player: -1
    tnt: 20
    wind_charge: 8

Despawn Distance

Reduce mob spawn and despawn distances to keep fewer entities loaded:

# server.properties
spawn-monsters=true
mob-spawn-range=4
entity-activation-range=animals=16 monsters=24 raiders=32 misc=8

Common Entity Lag Sources

  • Mob farms producing thousands of entities
  • Dropped items from large builds or gravity block drops
  • Villager breeding unchecked in trading halls
  • Minecart networks with many active carts

Use ClearLagg or similar plugins to periodically remove excess items and ground entities.

Chunk Loading Optimization

Paper Chunk Loading Settings

Paper provides chunk loading controls in paper-global.yml:

chunk-loading:
  auto-save-interval: default
  max-auto-save-chunks-per-tick: 24
  fix-villager-trading-dupe-exploit: true
  light-queue-size: 20
  load-chunks-in-parallel: true

chunk-sending:
  max-chunks-sends-per-tick: 40
  rate-limit: 800

Player Loading Settings

Control how many chunks are sent to each player per tick:

# paper-global.yml
player-chunks:
  min-load-radius: 2
  max-concurrent-sends: 16
  max-send-rate: 800

Paper-Specific Optimizations

Paper includes many optimizations not available in Vanilla or Spigot. Key configurations in paper-global.yml:

collisions:
  enable-player-collisions: true
  max-entity-collisions: 2

mob-spawn-range: 4
entity-activation-range:
  animals: 16
  monsters: 24
  raiders: 32
  misc: 8
  water: 8
  villagers: 16
  flying-monsters: 24

tick-rates:
  behavior:
    villager: 2
  sensor:
    villager_secondary_poi: 40
    nearest_bed: 80
    nearest_player: 20

These settings reduce unnecessary entity processing without noticeable gameplay impact.

FAQ

What is the single most effective performance improvement?

Switch from Vanilla to Paper. Paper includes dozens of optimizations and runs significantly faster with the same hardware. See Minecraft Server Types Compared for details.

My TPS is fine but players still experience lag.

Check network latency. Players far from your server location will experience high ping regardless of TPS. Minecraft Server Hosting offers Frankfurt and Salt Lake City locations to minimize latency for your player base.

How do I diagnose what is causing lag?

Install Spark, run a 60-second profile during peak lag, and review the report. It will identify the exact plugin, mod, or game system consuming the most tick time.

Should I use a profiler on a production server?

Yes. Spark has minimal overhead (under 1% CPU) and is safe to run on production. Avoid running continuous profiling; use time-limited sessions instead.

Can pre-generating chunks cause problems?

Pre-generation itself is safe. The only consideration is disk space: a 10,000-block radius overworld uses roughly 2-4 GB. Ensure you have sufficient storage.

Why does my modded server lag more than vanilla?

Mods add new block types, entities, tick handlers, and data structures. Each mod adds processing overhead. Heavy tech mods (Create, Mekanism) with many active machines are particularly demanding. See RAM Requirements for modded server memory recommendations.

What view distance do you recommend for a public server?

Start with view-distance 8 and simulation-distance 4. This provides good visibility while keeping server load manageable. Increase only if your Spark profile shows spare tick budget.

Does Folia eliminate the need for these optimizations?

Folia helps with CPU-bound servers but does not reduce total work. You still need proper RAM allocation, pre-generation, and entity management. Folia is best for servers with 100+ players. See Server Types Compared for when to use Folia.