Diagnosing Server-Side Lag
Resolving Minecraft Lag
You might experience lag while playing Minecraft for a variety of reasons. This article describes causes and potential solutions of server-side lag. For information about other types of lag, read through our article Resolving Minecraft Lag
The Minecraft game server is the part of the game that processes everything that happens while playing. If you are in single-player, there is still an internal server that runs on your computer that your client is connected to locally. There are a lot of different things that can cause server side lag. It's usually relatively easy to determine if the lag you are experiencing is server-side, but it can be difficult to determine the exact cause.
We're Here to Help
It can be difficult to determine the cause of server-side lag. There are a lot of potential culprits, and sometimes multiple things are causing issues at once. If you're running into a problem and you've purchased a server through us, make sure to contact us for support!
Minecraft Game Tick
The best indicator of server-side lag is whether or not the server can keep up with ticking the game on a regular schedule. One of the first things you might see when you experience lag is a message like this in your console or logs:
[Server thread/WARN]: Can't keep up! Is the server overloaded? Running 32245ms or 644 ticks behind
This log output isn't always a cause for concern. Sometimes you might see this when you first start your server or intermittently while playing. But if you do see this message a lot and you are experiencing lag while playing, you will want to use one of the tools detailed later in this article such as Spark.
So what is a game tick? Think of it like the "tick tock" of a clock. A game tick is a periodic interval of time and the game attempts to process everything during each game tick. A game tick should take no longer than 50 milliseconds. If it does take longer, that's when the server is considered to be lagging. It's entirely possible for the server to lag a few ticks and catch up while you as a play don't notice anything happening. So in most cases, lag is considered to be when the server is continually unable to keep up and has to start skipping game ticks.
What is processed during a game tick? The game client handles rendering, sound output, and control input from mouse and keyboard (or a gamepad/controller). That leaves everything else such as:
- Players and Mobs moving in the world.
- Loading and Unloading chunks.
- Placing and breaking blocks.
- Collision checking between objects in the world and processing damage done to players / mobs.
- Processing machines, magic rituals, or any sort of thing that a mod might be doing.
As you can see, a lot of work is done by the server. That can make it somewhat difficult to know exactly what is causing lag. Don't worry though as there are a lot of tools you can use.
How to Get Server Tick Rate
Now that you have a general understanding of game ticks, you will need to know how to determine your server's current tick rate to know if it's lagging. The vanilla version of Minecraft doesn't offer any simple to use utilities for determining the game's current tick rate. You will need to use other tools or if you are an Akliz user, contact us for support.
You can use one of these commands depending on your game type:
Game Type | Mod / Plugin | Command |
---|---|---|
Minecraft Base Minecraft | Built-in | debug start/start |
Minecraft Forge | Built-in | forge tps |
Minecraft Forge | Spark | spark tps |
Minecraft Fabric, Quilt, etc. | Spark | spark tps |
CraftBukkit, Spigot, Paper, etc. | EssentialsX | tps |
CraftBukkit, Spigot, Paper, etc. | Spark | spark tps |
Common Causes of Server-Side Lag
Regions and Chunks
The world is divided into region files stored on the server inside the world's folder. Each region is divided into an area of 32x32 chunks, which contain a 16x16 area of blocks going from the bottom to the top of the world. Chunks contain everything you see in the world. Typically, the more stuff in a single chunk, the more that chunk can lag.
Each player loads a certain number of chunks in the world depending on the server's
view-distance
property. The default view distance is10
which means that there will be a radius of 10 chunks surrounding each player that is loaded and updated in each game tick.
Tools to Help You Diagnose Lag
These mods are great at finding sources of server/TPS lag. The mod name of each is linked to support articles that explain how to use them.
Mod Name | Mod Function | Minecraft Versions | Client/Server |
---|---|---|---|
LagGoggles | Scan for lag in-game with 3D lag overlay and more | 1.10.2-1.12.2(Forge) | Both |
Observable | Scan for lag in-game with 3D lag overlay and more | 1.16.5-1.20.4(Forge and Fabric) | Both |
Spark | Take detailed scans of per-tick thread performance, useful for finding lag | 1.12.2-1.20.4(Forge), 1.15.2-1.20.4(Fabric) 1.8-1.20.x(Spigot) | Server |
Opis | Take Detailed scans of per-tick thread performance, useful for finding lag | 1.6.4-1.7.10(forge) | Server |
For additional mods that can help your server performance please check out our Performance Mods Article.
View Distance and Simulation Distance are Too Large
Your server might lag from having too many chunks loaded at once. This can happen if you have a really popular server with a lot of connected players or if you are playing with a demanding modpack. Depending on your version of Minecraft, the setting you need to change will be different.
Property | Version Added | |
---|---|---|
view-distance | 1.6.1 | Edit view distance |
simulation-distance | 1.17 | Edit simulation distance |
Exploration Causing Lag
Whenever you first start your server, you may notice some lag immediately while people are exploring. Exploring the world requires the server to generate new chunks, which takes more processing time than loading existing chunks. Every time you see a new chunk, that chunk is generated by the server. You can reduce your server's view-distance or simulation-distance to help.
World Pregeneration
When exploration is causing lag, the best solution is to pregen some of your world. It's much faster to load existing chunks from the server's storage drive than it is to generate entirely new chunks from scratch while you're playing. Depending on your version of the game and whether or not you are using mods/plugins, the tools you can use will vary. Below is a table of recommended tools, but you could use any other datapack, mod, or plugin that does the same thing. Some modpacks even have one of these mods provided, so you will want to check there first if you are playing a modpack.
Game Type | Mod Type | |
---|---|---|
Minecraft | Datapack | world-pregen |
Minecraft Forge | Mod | Chunky (Forge) |
Minecraft Fabric | Mod | Chunky (Fabric) |
CraftBukkit, Spigot, Paper, etc. | Plugin | Chunky (Bukkit) |
For information about how to install one of these tools:
- Install a Datapack
- Install Forge Mods on a Server
- Install Fabric Mods on a Server
- Install Plugins on a Server
Too Many Entities Causing Lag
Another common issue is too many entities in the world. One of your players might have blown something up resulting in tons of unplaced blocks. Another may have spawned hundreds or thousands of monsters. Each one of these items or mobs will use CPU and memory resources, and when there are many, will cause a noticeable impact on performance.
Minecraft versions prior to 1.8
CraftBukkit, Spigot, and Cauldron were issued DMCA takedown notices. Because of this, CraftBukkit and Cauldron are no longer publically available. Spigot was largely rewritten for Minecraft 1.8+, but still suffers in a legal gray area.
To remove entities in Minecraft versions prior to 1.8, make sure you're running a server that can support CraftBukkit plugins such as CraftBukkit, Spigot, or Cauldron. Next, install Essentials or WorldEdit and run one of the appropriate commands. If you are running a Forge based server, you can use ForgeEssentials or the Forge version of WorldEdit for similar features:
- Essentials:
/remove all
- WorldEdit:
/clear items -1
Minecraft versions 1.8 and higher
To remove entities, you can use the kill
command. You can Learn how to use commands in general and find more information about the kill command specifically on the Minecraft Wiki, but an example command to remove all items on the ground would be:
kill @e[type=item]
If you are running a Forge based server, you have a lot of options for mods that can help you. We recommend trying Crash Utilities. As an example, you could use one of these commands to remove hostile or passive mobs from the world:
crashutilities entities remove hostile force
crashutilities entities remove passive force
Too Many Chunks Loaded
In vanilla Minecraft, there is only one chunk that is loaded when you're not around, and that is the spawn chunk. However, in modded Minecraft, there are a lot of mods that offer the ability to keep a chunk loaded even when people aren't nearby. Some functions of mods require this, so it has its uses.
However, some players get in the habit of loading all of their chunks so that items can be created while they are offline. This causes a bunch of chunks to continue working even when no one is on the server. Servers should always limit chunk loading as a rule. We would also recommend that you turn off "easy" chunk loaders like the one found in FTB Utilities. Just check the configs of the mod and look for chunk loading references. Turn them off if possible.
Your Server is Running into its Memory Limit
Applications like Minecraft require having a set amount of memory allocated to turn the game on. Your game may not use all of the memory you allocate under normal conditions. Java's memory cleanup process, garbage collection, will attempt to keep empty space in your allocated memory and doing so is a CPU intensive process. The less available memory you have, the more aggressively Java will attempt to clear space, which can cause severe lag.
Your server may also use up all of the allocated memory and overflow. For example, if your server has 4gb of memory but it is trying to use 4.5gb, your server will crash with an OutOfMemoryError
. Without using a profiling tool, you can't determine if your server is nearing the memory limit.
If you suspect that this is an issue, contact us and we can help. With a vanilla server, we can use profiling tools such as Java VisualVM. If you have a modded server, you have different options such as using Spark on a Minecraft Forge based server.
Lack of Server Restarts is Causing Lag
If you've been playing on your server for a few days and it just keeps getting laggier and laggier every day, you probably haven't restarted in a while. A regular restart helps to keep the servers nice, fresh, and happy. You should use our scheduler to create automatic restarts at least twice a day:
- Log into Command Center.
- Click on the gear icon and then on
Scheduled Tasks
. - Click on
Schedule Restart
. - Pick a time for your scheduled task to begin and set the
Restart Every
option to 12 hours, or even 6 hours. - Click
Schedule Command
, and set it for 5 minutes before your restart. - Then set the command to something like
say Server restarting in 5 minutes.
This will give your users a warning before the server suddenly restarts. - Click
Save
.
Recommended Automatic Restarts
For 1.7.10 or lower, we recommend at least 12 hour restarts. For 1.8 or higher, we recommend every 6 hours.
Adaptive Restarts
To help combat server lag issues, we have added Adaptive Restarts to all Minecraft servers. Command Center will automatically detect when the server hasn't been restarted for a period of time and will restart the server if there are no players connected. However, it's still best to schedule restarts so that you can control when they happen.
Bukkit Plugins Causing Lag
To check plugin resource usage, use the Bukkit /timings
command, and scrutinize the output.
- Make sure you’re running CraftBukkit.
- Change
plugin-profiling
inbukkit.yml
fromfalse
totrue
. - Restart.
When you start experiencing lag, run: timings merged
. The command produces a timings[n].txt
file in the timings
folder. Open it and look at how many seconds it took to process each plugin. If you need an easy to use timings file interpreter, try this timings tool. The ones that take the longest should be the most of concern. You can try temporarily disabling them and seeing if the lag improves.
Updated 7 months ago