Finding and fixing lag
"The server is lagging" can mean three different problems, and each has a different fix. This guide shows how to tell them apart, how to find the real cause with a profiler, and which settings make the biggest difference on a Java server.
TPS, ping and FPS
- TPS (ticks per second) is how fast the server runs the game. A healthy server does 20 ticks every second, which gives it 50 milliseconds for each tick. When a tick takes longer, TPS drops and everyone sees the same symptoms: mobs freeze then jump, blocks reappear after you break them, crops grow slowly and redstone runs in slow motion.
- Ping is how long a message takes to travel between a player and the server. High ping affects only that player: hits land late and they rubber-band when they move, while everyone else is fine. Ping mostly depends on how far the player is from the server. Pat Host servers run in the UK, Texas, Sydney and Beauharnois in Canada, so a player in Australia on a UK server will always have high ping, whatever the settings.
- FPS (frames per second) is how smoothly a player's own game draws the picture. Low FPS comes from that player's device, not the server; a lower render distance or a mod such as Sodium helps them.
So first ask: is everyone affected, or just one person? Only low TPS is fixed on the server.
Measuring TPS
On Paper and Purpur, type tps in the console. It shows the average over the last 1, 5 and 15 minutes. Paper also has mspt, which shows how long ticks take in milliseconds. Under 50 ms is fine; anything that sits above 50 means the server cannot keep up.
Finding the cause with spark
spark is a free profiler that records what the server spends each tick on and shows it in your browser. Recent Paper builds include it already, so try spark in the console first. If the command is not found, install spark from the Plugins tab (or the Mods tab on Fabric) and restart. See installing plugins.
- Wait until the server is lagging, ideally with players online.
- Run
spark profiler startin the console. - Leave it running for a few minutes.
- Run
spark profiler stop. spark prints a link to the results. - Open the link and expand the Server thread entry. That is the main thread, where a tick is run.
Keep expanding the largest percentages. What you find at the bottom tells you where to look:
- A plugin's name taking a large share means that plugin is the problem. Check its settings, update it, or replace it.
- Entity ticking means too many mobs, animals or dropped items.
- Block entities or hoppers usually point to large farms, storage systems or redstone.
- Chunk generation or loading means players are exploring new land faster than the server can create it.
For lag that comes and goes, spark profiler start --only-ticks-over 100 records only ticks that took longer than 100 ms, so the slow moments stand out. spark health gives a quick summary of TPS, CPU and memory.
View distance and simulation distance
These two settings in server.properties have more effect on performance than almost anything else.
view-distanceis how many chunks around each player are sent to them, so they can see the land.simulation-distanceis how many chunks around each player are actually running: mobs moving, crops growing, redstone working.
The work grows with the area, not the distance, so going from 10 to 6 cuts the area to roughly a third. A good starting point for a small server is view-distance=8 and simulation-distance=5. Restart the server after changing them.
Pre-generating the world with Chunky
Creating new chunks is one of the heaviest jobs a server does. If players explore on elytra, the server can spend most of each tick generating terrain. The fix is to generate the land in advance with Chunky, available from the Plugins tab.
- Decide how big the world should be, and set a world border so players cannot go beyond it, for example
worldborder set 6000for 3,000 blocks in each direction. - Run
chunky radius 3000, thenchunky start. - Leave it running. It shows its progress in the console.
chunky pauseandchunky continuestop and resume it. - Repeat for the Nether with
chunky world world_netherif needed (a smaller radius is usually enough).
Pre-generation uses a lot of CPU, so run it while few people are playing. It also uses disk space: a large radius can take several gigabytes, so check your disk before starting. Free servers are stopped after a while when nobody is online; Chunky remembers its progress, so run chunky continue after the next start.
Farms, entities and redstone
On most survival servers, the biggest load is what players build. Common culprits:
- Animal pens with hundreds of animals. Every animal is checked every tick. Ask players to keep breeding pens small.
- Mob farms that never empty, and piles of dropped items lying on the ground.
- Long hopper chains. Each hopper checks for items many times a second. Water streams into a single hopper are far cheaper.
- Redstone clocks left running when nobody is using the machine.
spark will show which of these is the issue. Paper can then find the exact place: paper entity list counts entities by type, which helps you track down the farm.
Paper settings worth knowing
On Vanilla, switching to Paper or Purpur is often the biggest single improvement. The Versions tab can switch for you. Once on Paper, a few settings are worth a look:
spigot.ymlentity activation range: mobs further away than this are ticked less often.spigot.ymlmerge radius: nearby dropped items and experience orbs merge into one, so there are fewer entities.config/paper-world-defaults.ymlredstone implementation: setting it toALTERNATE_CURRENTmakes redstone dust much cheaper with very few differences in behaviour.- Despawn ranges in the same file: lowering them clears unwanted mobs sooner.
Change one setting at a time and measure again. Some changes affect farms, so tell players first.
When more memory does not help
Adding memory is the usual reaction to lag, and often the wrong one. A Minecraft server does nearly all its game work on one main thread, so low TPS is usually a CPU-time problem: too much to do in each tick. Extra memory does not make that thread faster.
Memory helps only when the server is actually short of it. Signs of that are OutOfMemoryError in the console, or spark showing memory staying nearly full with frequent garbage collection.
On Pat Host the startup command sets Java's memory limit (-Xmx) for you, at 90% of the server's RAM plus swap, leaving the rest for Java's own overhead. Do not raise -Xmx yourself: if Java grows past what the server has, the server is killed. If the server really is short of memory, give it more RAM under Settings → Server Resources, within your server's limits.
Common problems
- Lag only when someone flies around. Chunk generation. Pre-generate with Chunky and set a world border.
- Lag started after adding a plugin. Remove it and measure again.
- One player lags, others do not. That is ping or FPS on their side, not server TPS.
- Lag at the same time every day. Check the Schedules tab and plugins for timed tasks such as backups or big clean-ups.
If you have a spark link and cannot read it, share it in a ticket in our Discord. Before big changes, take a backup; see backing up and restoring.
