01
Measure before you tune: TPS and MSPT
A Minecraft server computes the world in "ticks": 20 per second when all is well, so 50 milliseconds at most for each one. Two figures tell you where it stands:
- TPS (ticks per second): 20 is both the target and the ceiling. Below that, the world slows down for every player;
- MSPT (milliseconds per tick): the time actually spent computing a tick. As long as it stays under 50, the server holds its 20 TPS.
MSPT is the more useful figure. A server at 20 TPS may be running at 15 ms per tick, with plenty of headroom, or at 48 ms, on the edge: TPS reads 20 in both cases and only moves once the limit is passed. Four commands give these values:
/tps
/mspt
/spark tps
/tick query
/tps (Paper, Purpur): average TPS over 1, 5 and 15 minutes;
/mspt (Paper, Purpur): average, minimum and maximum tick time over 5 seconds, 10 seconds and 1 minute;
/spark tps: TPS, MSPT (minimum, median, 95th percentile, maximum) and CPU usage;
/tick query: the base game's own command since version 1.20.3. It gives the average time per tick and its percentiles, including on a Vanilla or Fabric server with nothing installed.
On Purpur, /tpsbar also shows a bar at the top of the screen with TPS, MSPT and ping, until you type the command again. To read the numbers: an average under 40 ms leaves headroom, between 40 and 50 the server needs watching, above 50 TPS drops. Look at the maximum too: a 20 ms average with 300 ms spikes means stutter, typical of chunk generation, a world save or a Java memory pause.
Measure during the slowdown, with your players online. If MSPT is low and a single player complains, the problem is their connection or their computer, not the server. The guide how much RAM for a Minecraft server explains how to tell a memory shortage from a processor shortage.
02
Find the cause with spark
spark is a profiler: it samples what the server is doing and produces a report showing where the time of each tick goes. Since version 1.21, Paper ships it built in; the older Timings reports, turned off by default in 1.21, no longer work at all since 1.21.3. On an older version, or on Fabric, Forge and NeoForge, install the spark plugin or mod (see essential plugins).
/spark profiler start --timeout 600
/spark profiler start --only-ticks-over 50
/spark profiler stop
/spark health
/spark gc
--timeout 600 stops the profile after 10 minutes and prints the report link. Without it, finish with /spark profiler stop;
--only-ticks-over 50 keeps only ticks longer than 50 ms: the right mode for occasional spikes that an average would hide;
/spark health sums up the machine (TPS, CPU, memory, disk) and /spark gc shows how often and how long Java's garbage collector runs.
Start the profile while the server is lagging, let it run for a few minutes, then open the link. The report reads like a tree: expand the server's main thread (Server thread) and follow the branches with the largest percentages. Four cases come up almost every time:
- a plugin or a mod at the top, recognisable by its name in the sources view: update it, configure it or replace it;
- entities: a mob farm, an overcrowded pen, dozens of villagers;
- blocks: hopper chains, redstone clocks, pistons;
- chunk generation, when players explore new areas.
Each has its remedy in the sections below. Change one setting at a time, then measure again: it is the only way to know what helped. On a modded server, the profile often points to one specific mod: the guide install a modpack gives the method to isolate it.
03
Tune view-distance and simulation-distance
These two lines of server.properties default to 10 and accept 3 to 32. They do not act on the same thing:
simulation-distance: the radius, in chunks around each player, in which the world is computed (monsters, animals, crops, redstone). This is the one that weighs on the processor, and therefore on MSPT;
view-distance: the radius of chunks sent to the player. It weighs on memory, network and chunk loading, far less on computation.
So you can keep a distant horizon while computing less: beyond the simulation distance, the player sees the terrain, but nothing moves there. A common starting point for a busy server:
view-distance=8
simulation-distance=5
Lower simulation-distance first, one step at a time, measuring MSPT at each step. Two effects to know before going too low:
- a farm only works inside the simulated area: with a short distance, it stops as soon as the player moves a few chunks away;
- in
spigot.yml, mob-spawn-range (8 by default) sets how many chunks from players monsters spawn. Keep it lower than or equal to the simulation distance: monsters only spawn inside the simulated area.
On Paper and Purpur, spigot.yml also accepts view-distance and simulation-distance per world (set to default at first), which lets you reduce the End, for example, without touching the main world. The file is only read at startup: restart after each change. The other lines are covered in the guide server.properties explained.
04
Pre-generate the world and set a border
Creating a new chunk costs far more than reading back a chunk already saved. When several players explore at once, especially with an Elytra, the server generates non-stop and MSPT soars. The answer: bound the world, then generate the whole area in advance, once and for all.
Set the world border first. The value given to /worldborder set is a diameter in blocks: 10000 gives a map of 5000 blocks on each side of the centre.
/worldborder center 0 0
/worldborder set 10000
Then install Chunky (a plugin for Paper and Purpur, a mod for Fabric, Forge and NeoForge) and start the generation:
chunky world world
chunky worldborder
chunky start
chunky worldborder takes the centre and radius from the border. Without a border, give them yourself, the radius being in blocks:
chunky world world
chunky center 0 0
chunky radius 5000
chunky start
chunky pause pauses the task and keeps its progress, chunky continue resumes it, chunky cancel drops it (chunks already created stay);
- repeat the operation for the Nether (
chunky world world_nether) and the End if your players go there often. Depending on the game version, the border is shared by all dimensions or set for each one: check it in all three;
- generation keeps the processor busy and fills the disk: run it at night or before opening, and watch the free space. A 5000-block radius is enough for most survival servers.
05
Entities, farms and redstone: Paper and Purpur settings
Moving from the Vanilla server to Paper or Purpur keeps most of the game's behaviour (although Paper fixes some exploits, such as item duplication) and opens up four configuration files. On Paper, /paper entity list first counts entities by type, which is often enough to spot the pen or farm at fault. The values below are cautious starting points, with the default recalled each time.
bukkit.yml: the number of creatures and how often they spawn. By default, monsters is 70, animals 10, ambient 15 and monster-spawns 1. On Paper, these caps are counted per player (per-player-mob-spawns setting, on by default).
spawn-limits:
monsters: 50
animals: 8
ambient: 1
ticks-per:
monster-spawns: 10
spigot.yml: the distance, in blocks, within which a creature keeps its full behaviour (32 by default for animals, monsters and villagers), and the merge radius of items on the ground (0.5 by default) and of experience orbs (-1 by default, meaning disabled).
world-settings:
default:
entity-activation-range:
animals: 16
monsters: 24
villagers: 16
merge-radius:
item: 3.5
exp: 4.0
config/paper-world-defaults.yml: collisions between entities (8 by default), fast despawn of worthless items, explosions and the redstone engine (VANILLA by default).
collisions:
max-entity-collisions: 2
entities:
spawning:
alt-item-despawn-rate:
enabled: true
items:
cobblestone: 300
netherrack: 300
environment:
optimize-explosions: true
misc:
redstone-implementation: ALTERNATE_CURRENT
Each setting has a cost, which your players should hear about:
- spawn caps set too low empty mob farms;
- a short activation range slows down animal farms and villagers far from players;
ALTERNATE_CURRENT and EIGENCRAFT compute redstone dust much faster, but change its behaviour slightly: test your most technical machines before adopting one;
nerf-spawner-mobs (spigot.yml) removes the behaviour of monsters that come out of a spawner: very effective, but some farms stop working;
hopper.disable-move-event (config/paper-world-defaults.yml) lightens hoppers, but breaks plugins that watch their transfers (chest protection, sorting): leave it at false if you use any.
Purpur adds purpur.yml. The most useful option here targets trading halls: off by default, it switches off the AI of a villager that cannot move, without disabling trading with it.
world-settings:
default:
mobs:
villager:
lobotomize:
enabled: true
On the game side, the cramming rule limits how many entities can stand on the same block (24 by default; it is called maxEntityCramming up to 1.21.10 and max_entity_cramming since 1.21.11). Finally, a few habits are worth all the settings: a switch on every redstone clock, pens limited to a few dozen animals, and no farm left running under an idle player all night.
06
Memory and JVM flags: Aikar's flags, with caution
Memory is only at fault if the measurements say so: an OutOfMemoryError, memory that stays full right after the garbage collector has run, or long and frequent pauses in /spark gc. In every other case, adding memory changes nothing to MSPT. For sizing, see how much RAM for a Minecraft server.
"Aikar's flags" are a set of launch options for Java's G1 garbage collector, reproduced in the Paper documentation. They shorten memory pauses, and therefore stutter; they do not speed up world computation and fix neither a slow plugin nor an oversized farm. The line published by Paper, here for an 8 GB machine:
java -Xms6500M -Xmx6500M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar --nogui
The precautions that go with it:
- same value for
-Xms and -Xmx, as the Paper documentation recommends;
- do not give Java all of the machine's memory: take off 1000 to 1500 MB for what Java uses outside its heap and for the system, hence 6500 MB out of 8 GB. Without that margin, the server risks being killed abruptly;
-XX:+AlwaysPreTouch reserves all the memory at startup: a panel showing memory as full then indicates nothing abnormal;
- copy the whole line, without mixing in other options found elsewhere: these flags are tuned to work together;
- a huge heap does not help: beyond what the server uses, extra memory makes nothing faster.
On a VPS, this line goes in your start script or service (see install a Minecraft server on a VPS). With a hosting provider, the launch line is often managed by the panel: ask support before touching it. Either way, compare /spark gc before and after; if nothing changes, the cause of the lag is elsewhere.
07
On a CloudFive server
On a CloudFive Minecraft plan, the steps of this guide are done from the server's page, in the client area:
- Console: type
tps, mspt or spark profiler start --timeout 600, without the slash. CPU, memory, disk and player count stay displayed above the logs while you measure;
- Version: moving from Vanilla to Paper or Purpur is done by choosing the loader and the version; a backup is taken before the change;
- Plugins: Chunky installs from Modrinth, with no file to upload;
- Server properties:
view-distance and simulation-distance are lines of server.properties, whose properties are set from the server's page, translated, without editing the file by hand;
- Files:
bukkit.yml, spigot.yml, config/paper-world-defaults.yml and purpur.yml open in the file editor;
- Backups: create one before changing settings. Automatic backups cover 5 rolling days and restore in one click;
- Plan: if spark shows a real memory shortage, you change tier from the client area, without reinstalling or losing your worlds.
On the hardware side, every tier runs on a Ryzen 9 9950X with DDR5 and NVMe, in France, with Anti-DDoS Premium included: the high clock speed of each core is what matters for Minecraft's main thread. If MSPT stays high while spark points to no plugin, farm or chunk generation, open a ticket from the server's page and attach the report link: support answers in French, 7 days a week.
08
Frequently asked questions
Why does my Minecraft server lag when the RAM is not full?
Because lag most often comes from the processor: Minecraft computes most of the world on a single thread. Measure MSPT, then run a spark profile to see whether the time goes into a plugin, entities, redstone or chunk generation.
What is a good MSPT on a Minecraft server?
Under 50 milliseconds, the server holds 20 TPS. An average under 40 ms leaves headroom; between 40 and 50, the server is at its limit. Look at the maximum too: very high spikes cause stutter even with a good average.
What simulation-distance should I set on a Minecraft server?
10 by default, from 3 to 32. On a busy server, go down step by step towards 5 or 6 while measuring MSPT: it is the setting that relieves the processor the most. Farms only run inside the simulated area around players.
How do I use spark on a Minecraft server?
Type /spark profiler start --timeout 600 while the server is lagging: after 10 minutes, spark prints a link to a report showing where the time of each tick goes. spark is built into Paper since version 1.21; elsewhere, it installs as a plugin or a mod.
Do Aikar's flags fix Minecraft server lag?
No. These Java options tune the G1 garbage collector to shorten memory pauses, and therefore some stutter. They do not speed up world computation: a slow plugin, too many entities or chunk generation are handled differently.
Should I pre-generate the map of a Minecraft server?
Yes, as soon as players explore: creating new chunks is one of the heaviest tasks for the server. Set a world border, then generate the whole area in advance with Chunky, preferably at night or before opening.