SamsCreations
SamsCreations

Why is my Minecraft server lagging? How to find the cause and fix it

Sam1qk_8 min read

Server lag, ping and low FPS are three different problems. How to tell which one you have, find the real cause with spark, and the settings, plugins and habits that actually make a server run smoother.

Sam facepalming

"The server is lagging" is probably the message I've seen most in Discord support channels. And almost every time, the first fix people try is the wrong one: more RAM, a different host, or deleting random plugins until it feels better.

Lag has causes, and you can find them. This is how I'd go about it, from figuring out what kind of lag you have to the settings that actually help.

First: which lag is it?

Players say "lag" for three completely different things. Fixing the wrong one wastes your time.

What players seeWhat it really isWhose problem
Blocks come back after breaking them, mobs freeze, everything feels slow for everyoneServer lag (low TPS)The server
Only one player rubber-bands or gets hit late, everyone else is fineHigh ping (network)That player's connection, or the distance to the host
The game stutters even in singleplayer, low frame rateLow FPSThe player's computer

Only the first one is something you fix on the server. If one player lags and nobody else does, it's almost always their connection. If they stutter everywhere, it's their PC, their settings or their shaders.

TPS and MSPT, in plain words

The server runs the game in ticks. A healthy server does 20 ticks per second (TPS). Each tick has 50 milliseconds to finish everything: moving mobs, growing crops, running redstone, running plugins.

MSPT (milliseconds per tick) tells you how long a tick actually takes.

MSPTWhat it means
Under 30Comfortable, plenty of room
30 to 50Fine, but you're using most of the budget
Over 50The server can't keep up, TPS drops below 20 and everyone feels it

MSPT is the more useful number. TPS stays at 20 right up until things go wrong, while MSPT shows you the problem coming. On Paper, /mspt shows it and /tps shows the TPS.

Find the cause with spark

Don't guess. Install spark, a free profiler that most server owners use. It's built into Paper in recent versions, and also available as a plugin.

When the server is lagging, with players online, run:

/spark profiler start

Wait a few minutes while the lag is happening, then:

/spark profiler stop

It gives you a link to a report showing what the server spent its time on. You don't need to understand all of it. Look for the biggest numbers near the top and you'll usually see one of these:

  • A plugin name taking a big share of the tick
  • Entities (mobs, items, villagers) ticking
  • Chunk loading or generation
  • Block entities like hoppers and furnaces

/spark health is also handy for a quick look at TPS, MSPT, CPU and memory in one place.

Sam looking through a spyglass

The usual causes, and what to do about them

CauseHow it shows upFix
Too many entitiesHuge mob farms, piles of dropped items, villager breedersLimit farms, clear items regularly, tune entity settings
Chunk generationLag when players explore new land, especially with elytraPre-generate the world
View and simulation distanceConstant load, gets worse with more playersLower them a little
Hoppers and redstone clocksLag around certain basesFind them with spark, ask players to switch clocks off
One heavy pluginA plugin near the top of the spark reportUpdate it, configure it, or replace it
Not enough RAM, or badly setLag spikes every few seconds or minutesGive it a sensible amount and use good startup flags
Weak or oversold hostingEverything is slow even when emptyBetter host, or a plan with a faster CPU

Entities

Entities are the most common cause I see. One player with a giant mob farm can lag the whole server. Some things that help:

  • Clear dropped items. Items on the ground disappear after five minutes, but a farm can drop them much faster than that.
  • Merge items and XP. spigot.yml has merge radius settings so nearby items and XP orbs combine into one.
  • Set limits. paper-world-defaults.yml has options to limit how many entities of a type can exist per chunk and how far away mobs despawn.
  • Talk to your players. Most people with a laggy farm don't know it's a problem. Tell them, and most will change it.

Chunk generation

Generating new terrain is one of the heaviest things a server does. When players fly in a straight line with an elytra, the server has to create the world in front of them in real time.

The fix is to generate the world in advance. A plugin like Chunky does this while nobody is online:

/chunky radius 5000
/chunky start

That generates everything within 5000 blocks of spawn. It takes a while, but afterwards exploring doesn't cost much. Pair it with a world border so players can't leave the generated area.

View distance and simulation distance

These two settings in server.properties make a big difference:

  • view-distance is how far players can see.
  • simulation-distance is how far the world actually runs: mobs move, crops grow, redstone works.

Simulation distance costs the most, and players rarely notice it going down a bit. A common starting point is a view distance around 8 to 10 and a simulation distance around 6 to 8. Lower them slightly if you're short on power, and test how it feels.

Plugins

If a plugin shows up near the top of the spark report, first update it. Many performance problems are fixed in newer versions. Then look at its config for anything that runs on a timer or for every player. If it's still heavy, ask the author with the spark link, or look for an alternative.

Also remember: every plugin costs something. Fifty plugins you barely use are fifty things running in the background. I wrote more about choosing plugins in the best plugins guide.

RAM: more is not always better

The most common advice online is "give it more RAM". Sometimes that's right, often it isn't.

ServerRough amount
A few friends, survival3 to 4 GB
Small public server, some plugins4 to 6 GB
Busier server or big modpack-like setups8 GB and up

Too little RAM causes constant lag spikes. But giving a small server 16 GB doesn't make it faster, and with bad startup settings it can make the pauses longer. Memory also isn't the same as speed: a server with plenty of RAM can still lag because the CPU is too slow.

Use good startup flags. Most hosts already apply Aikar's flags, a well known set of Java settings made for Minecraft servers. If you run the server yourself, search for them and use them.

The host matters more than people think

Minecraft runs most of its work on one main thread, so single-core CPU speed matters more than having lots of cores. A cheap host packing many servers onto one machine will lag no matter what you change in the config.

Signs your host is the problem:

  • The server lags even when it's nearly empty
  • spark shows no clear cause, everything is just slow
  • Lag comes and goes at the same times every day (busy hours for the machine)

Look for hosts that tell you which CPU you get, and keep the server close to your players to keep ping down. I went through choosing a host in my server setup guide.

Software that helps

  • Paper instead of Spigot or vanilla. It's much faster and fixes a lot of lag sources out of the box.
  • Purpur, built on Paper, adds even more settings if you like to tweak.
  • Folia splits the world across CPU cores for very large player counts, but many plugins don't support it. For a normal server, stick with Paper.
Sam cheering with both arms up

A checklist when the server lags

  1. Check what kind of lag it is. Everyone, one player, or FPS?
  2. Look at MSPT with /mspt or /spark health.
  3. Run a spark profile during the lag.
  4. Fix the biggest thing first. One farm or one plugin is often most of the problem.
  5. Pre-generate the world if exploring causes it.
  6. Adjust view and simulation distance if the load is constant.
  7. Check RAM and startup flags.
  8. Consider the host if nothing else explains it.

Questions people ask a lot

Will a lag-removing plugin fix it?

Usually not. Plugins that promise to "remove lag" mostly clear entities on a timer or change settings you can change yourself. Some do more harm than good by killing farms and annoying players. Find the cause instead.

Why does it only lag when a certain player is online?

Their base is probably the cause: a big farm, a lot of hoppers or a redstone clock that only runs while their chunks are loaded. A spark report taken while they're online usually shows it.

Can too many players cause lag?

Yes, each player loads chunks and brings entities with them. But a well set up Paper server on decent hardware handles a lot more players than people expect. If 20 players already lag it, something else is usually going on.

Is it worth restarting the server every day?

A daily restart doesn't hurt and keeps memory tidy, and many servers do it. But if the server only stays smooth for a few hours after each restart, something is building up, and spark will show you what.

The short version

  • Figure out if it's server lag, ping or FPS before fixing anything.
  • Watch MSPT, not just TPS.
  • Use spark to find the real cause instead of guessing.
  • Entities, chunk generation and view distance are the usual suspects.
  • Pre-generate your world with Chunky.
  • More RAM isn't a fix on its own, and the host's CPU matters a lot.
  • Run Paper.