Tutorials
Configuring and managing your server

How to Fix Lag on your server

If you're running a Minecraft server, one of the most frustrating things that can happen is lag. This article will discuss several methods for fixing a laggy Minecraft server and optimizing its performance.

You can consult this article to identify the type of lag that you encounter.


Remove Tick / Lag Machines

Redstone machines are great for creating almost anything in Minecraft. However, having too many of these machines can decrease your TPS and cause lag for all players. To fix this, try to limit the number of machines and install anti-redstone-lag plugins like ClearLagg, which can help reduce lag caused by redstone machines. Additionally, it's best to avoid having too many automated farms, mob grinders, or anything else that would involve complex redstone mechanics. Always include a method to turn off your machines and farms so they are not running all the time and eating up your server's resources.


Pregenerate Your World

Pregenerating the world is a vital step in removing lag. It's best to do this before anything else. The Chunky plugin is a great tool for pregenerating your world. All you need to do is install the plugin and run the following commands:

/chunky radius 5000

followed by /chunky start

This will pre-generate a 5,000 block radius around your world spawn. The server will lag heavily while the process is running, but once it's done, your performance will improve dramatically. You can increase the radius as much as you like, but it's recommended to keep it under 20,000 blocks.


Optimize Your Config Files

Editing Paper.yml and other config files can greatly improve your server's performance. Some of the main files that you should modify are Bukkit.yml, Paper-world-defaults.yml, and Spigot.yml. Below are the settings you should change to get the best performance possible with minimal effect on your gameplay.


Bukkit.yml

spawn-limits:
  monsters: 50
  animals: 8
  water-animals: 7
  water-ambient: 10
  water-underground-creature: 5
  ambient: 1
chunk-gc:
  period-in-ticks: 400
ticks-per:
  animal-spawns: 400
  monster-spawns: 5
  water-spawns: 11
  water-ambient-spawns: 21
  water-underground-creature-spawns: 11
  ambient-spawns: 31
  autosave: 6000


Spigot.yml

  save-user-cache-on-stop-only: true
    max-tick-time:
      tile: 10
      entity: 20
    mob-spawn-range: 6
    entity-activation-range:
      animals: 16
      monsters: 24
      raiders: 48
      misc: 8
      water: 16
      villagers: 24
      flying-monsters: 24
    merge-radius:
      exp: 4.0
      item: 6.0
    tick-inactive-villagers: false
   nerf-spawner-mobs: true
   arrow-despawn-rate: 300
   trident-despawn-rate: 300


Paper-world-defaults.yml

   max-auto-save-chunks-per-tick: 6
   optimize-explosions: true
   disable-chest-cat-detection: true
   max-entity-collisions: 2
  container-update: 3
  grass-spread: 4
  mob-spawner: 3
    despawn-ranges (in 1.18+, use this setting for all despawn ranges.)
      soft: 28
      hard: 96
    hopper:
      cooldown-when-full: true
      disable-move-event: true
    non-player-arrow-despawn-rate: default
    creative-arrow-despawn-rate: default
   prevent-moving-into-unloaded-chunks: true
  redstone-implementation: EIGENCRAFT
  armor-stands:
    do-collision-entity-lookups: false
    tick: false
    per-player-mob-spawns: true
    alt-item-despawn-rate:
      enabled: true
      items:
        COBBLESTONE: 300
        NETHERRACK: 300
        SAND: 300
        DIRT: 300
        GRAVEL: 300
    anti-xray:
      enabled: false
      engine-mode: 2


Use Plugins

Plugins can significantly reduce lag on your Minecraft server. The following are some of the most recommended plugins for reducing lag:

ClearLagg 
ClearLagg is a plugin designed to remove lag caused by entities such as items, mobs, and more. It can also remove entities based on conditions such as age, type, or distance from players.

Limit Pillagers
This plugin limits the number of Pillagers that can spawn within a certain radius around players. This can help reduce server lag caused by too many Pillagers.

Village Optimiser
Village Optimiser is a plugin that optimizes village mechanics to reduce server lag. It includes features such as villager pathfinding improvements, improved iron golem spawning, and more.

MergedMobs 
MergedMobs is a premium plugin that merges mobs within a certain radius to reduce lag. It combines multiple mobs into a single entity, reducing the number of entities on the server.

Entity Tracker Fixer 
Entity Tracker Fixer is a plugin that fixes a bug in Minecraft where entities continue to be tracked even when players are far away. This can cause server lag, and the plugin helps to fix this issue.

Farm Limiter 
Farm Limiter is a premium plugin that limits the number of farms and spawners players can place on the server. This can help reduce server lag caused by too many farms.

Mob Farm Manager 
Mob Farm Manager is a premium plugin that optimizes mob farms to reduce server lag. It includes features such as improved mob spawning, optimized mob pathfinding, and more.

Lag Assist
Lag Assist is a premium plugin that optimizes various aspects of the game to reduce server lag. It includes features such as improved chunk loading, optimized entity handling, and more.

Spark
Spark is a plugin that helps optimize the performance of your server. It includes features such as better garbage collection, improved chunk loading, and more.

StackMob
StackMob is a plugin that reduces server lag by stacking mobs on top of each other. This reduces the number of entities on the server, helping to improve performance.

Armor Stand
Armor Stand-Limiter is a plugin that limits the number of armor stands that players can place on the server. This can help reduce server lag caused by too many armor stands.


Switch to PaperMC or its Forks

If you're running a Vanilla Minecraft server, you may think it won't experience lag. Unfortunately, the base game doesn't offer a lot of options for optimization and can be really laggy as a result. Newer updates such as 1.19+ have made the game a lot more resource-hungry. Switching to PaperMC or one of its forks like Purpur or Airplane will drastically improve your performance.

Conclusion

Optimizing your Minecraft server is crucial in preventing server lag. By removing tick/lag machines, pregenerating your world, optimizing your config files, using plugins, and switching to Paper or its forks, you can improve your server's performance and provide a lag-free gaming experience for your players.