- Nightkeeper
- Guides
- Fix lag
How to fix Minecraft server lag
"The server is lagging" can mean three different problems with three different fixes. Measure first, find the cause, and only then change settings or buy more RAM.
The short version
- If TPS is a steady 20, the problem isn't the server. It's the player's connection or their computer.
- Profile with spark before changing anything. It tells you exactly what's using the tick.
- Most server lag comes from a few places: too many entities, hoppers and redstone, generating new chunks, and view distance set too high.
1. Work out which kind of lag it is
| Symptom | Likely cause |
|---|---|
| Everyone sees blocks reappear, mobs freeze, furnaces slow down | Server lag: the server can't finish its work in time |
| One player rubber-bands while others are fine | That player's network connection |
| Low frame rate, stutter when turning, but the world reacts normally | The player's computer or client settings |
Only the first one is fixed on the server.
2. Measure TPS and MSPT
A Minecraft server runs 20 ticks per second (TPS), so each tick has 50 milliseconds. MSPT is how many milliseconds a tick actually takes. Below 50 is healthy. Above 50, TPS starts to fall and everyone feels it.
On Paper, /tps shows TPS over the last 1, 5 and 15 minutes and /mspt shows tick times. Watch them while the lag is happening, not afterwards.
3. Profile with spark
spark is a profiler built into recent Paper versions, and available as a plugin or mod elsewhere. Start it while the server is lagging:
/spark profiler start
(wait a few minutes while the lag happens)
/spark profiler stop
You get a link to a report that breaks the tick down by what used it: entities, block entities such as hoppers, chunk loading, or a particular plugin. /spark health gives a quick overview of TPS, CPU, memory and disk.
4. Fix the usual causes
Too many entities
Mob farms, villager breeders, item drops and boats or minecarts left lying around all cost tick time. On Paper, /paper entity list shows entity counts by type, which usually points straight at the farm or chunk responsible. Ask the owner to cap it rather than deleting it unannounced.
Hoppers and redstone
Large hopper chains, item sorters and redstone clocks that never stop are classic lag sources. The spark report shows them under block entities. A clock that runs while nobody is near it is worth turning off.
Generating new chunks
Players flying into new terrain with elytra force the server to generate chunks, which is one of the most expensive things it does. Pre-generate the world inside your border with a plugin like Chunky (/chunky radius 5000, then /chunky start) and set a world border so new generation stops.
View and simulation distance
In server.properties, view-distance controls how far players can see and simulation-distance how far the world keeps running around them. Lowering simulation distance to around 6 to 8 saves a lot of tick time while keeping a decent view distance.
Memory
If memory sits near its limit, the server spends time on garbage collection and stutters. Too little memory is the usual issue, but giving Java far more than it needs can also cause long pauses. If memory climbs steadily over hours and never drops, a plugin or mod is leaking and a restart only buys time.
5. Keep it from coming back
Lag usually returns with a new farm or a new build. Check TPS regularly at peak times, and when it drops, look at what changed since it was last fine.
How Warden handles lag
Warden, the AI staff team on every Nightkeeper server, watches TPS and memory continuously:
- When TPS drops and stays down, it finds the hottest chunk and the player who built the most hoppers or redstone there.
- It can clear runaway entities in that chunk, and tells you who and what caused the lag.
- It tracks memory pressure and slow leaks, and restarts the server after a crash, with crash-loop protection.