By Mateusz Jasiński · Updated
Find what lags your Paper server with spark
Command/spark profiler start --timeout 600Command/spark tickmonitor --threshold-tick 50To find what lags a Paper server, run /spark profiler start --timeout 600 while the lag is happening, open the link it prints after ten minutes, and follow the highest percentages down from the Server thread until you reach a plugin or a game system. For a lag spike that comes and goes, use /spark tickmonitor --threshold-tick 50 to catch the slow ticks first, then profile only those ticks with --only-ticks-over. Paper bundles spark since 1.21, so there is nothing to install.
First, tell lag from lag
"The server lags" can mean three different things, and only one of them is in a profile.
| What players see | What it usually is | Check with |
|---|---|---|
| Everything slows down: mobs stutter, blocks come back, furnaces crawl | The server misses its 50 ms tick budget | /spark tps, /mspt |
| One player rubber-bands, the rest are fine | That player's connection | /spark ping --player <name> |
| The whole server freezes for a second every few minutes | One very slow tick, often a garbage collection pause or a plugin task | /spark tickmonitor, /spark gc |
A Minecraft server aims for 20 ticks a second, which leaves 50 ms for each tick. MSPT (milliseconds per tick) is how much of that the server uses. Under 50 the server keeps up and TPS stays at 20; above 50 it starts to fall behind. That is why MSPT is the number to watch: TPS only moves once the headroom is already gone.
If the problem is one player's ping, no profile will show it. The rest of this guide is about the first and third rows.
Step by step: profile constant lag
Wait until the server is lagging
A profile of a healthy server shows a healthy server. Run it at the time of day when players complain, with the usual number of players online.
Start the profiler
Command/spark profiler start --timeout 600Config keyspark.profilerRun
/spark profiler start --timeout 600from the console or as an operator. This is the command Paper's own docs give: it samples for 10 minutes, stops by itself and prints a link to the report. The permission issparkorspark.profiler.Keep playing as normal
Do not restart, do not reload plugins and do not change configs during the run. You want the profile to show the lag, not your fixes.
Open the link
Command/spark profiler stop --save-to-filespark uploads the report to its viewer and gives you a URL. You can share that link with a plugin developer or in Paper's help channel as it is. If you cannot upload, stop with
/spark profiler stop --save-to-fileto keep it on disk instead.
Command/spark profiler stopIf the lag is gone before ten minutes are up, run /spark profiler stop to end the run early and get the link.
Reading the profile
The viewer opens on a list of threads. On Paper the one that matters is Server thread: it runs the whole game tick. Click it to expand it, and keep expanding.
The rule from spark's own docs is simple: follow the percentages. Each node shows how much of the thread's time it took. Keep opening the child with the highest share until you reach something with a name you recognise.
What you will pass on the way:
- APIMinecraftServer.tick()
MinecraftServer.tick()is where the work happens. Time spent sleeping or parked next to it is healthy: that is the server waiting for the next tick because it finished early. - Under the tick, world ticking (blocks, redstone, chunks) and entity ticking usually take the biggest shares.
- APICraftScheduler.mainThreadHeartbeat()
CraftScheduler.mainThreadHeartbeat()is plugin scheduler tasks. A large share here points at a plugin's repeating task. - Plugin event handlers show up under the event that called them, with the plugin's own package name further down.
The Sources view finds the plugin
If you only want to know which plugin is to blame, switch views with the eye button at the top. The Sources view shows one tree per plugin, each filtered to the calls that plugin made. A plugin that takes 30 percent of the tick is obvious there in a way it is not in the full tree.
The Flat view is the other shortcut. It lists the 250 slowest method calls at the top level. Sort by Self Time to find the method that does the work itself, rather than one that only calls something slow.
spark applies deobfuscation mappings by itself, so you see readable Minecraft method names. If names look scrambled, pick the mappings by hand in the dropdown at the top right.
What the usual findings mean
| Biggest share | Likely cause | What to try |
|---|---|---|
| Entity ticking | Too many mobs or item entities in loaded chunks | Find the farm or the dropped items, limit mob farms, check entity counts per chunk |
| Chunk loading or generation | Players exploring new terrain | Pre-generate the world before opening, lower view distance |
| One plugin in Sources | That plugin's task or event handler | Update it, check its config, send the profile link to its author |
| Hoppers and block entities | Large storage or sorting systems | Find the area with the most block entities and simplify it |
A profile tells you where the time went, not why. A plugin that shows up under an event handler may only be slow because another plugin fires that event thousands of times. Read the parent nodes too before you blame the name at the bottom.
Step by step: catch a lag spike
A short freeze every few minutes barely shows in a normal profile. spark's docs explain why: the profile averages every sample, and thousands of normal ticks hide the one slow tick. Separate the slow ticks first.
Find out how slow the spike is
Command/spark tickmonitor --threshold-tick 50Command/spark tickmonitorRun
/spark tickmonitor --threshold-tick 50. spark now posts a message for every tick that takes longer than 50 ms, the point at which the server starts to fall behind. If that is too quiet, lower the number. Run/spark tickmonitoragain to turn it off.Line it up with the game
Note when the messages come. A spike every time someone opens a menu, places a large build or a scheduled task runs tells you more than any profile.
Profile only the slow ticks
Command/spark profiler start --only-ticks-over 100Start the profiler with
/spark profiler start --only-ticks-over 100, using a value below the spike you saw but above a normal tick. spark's docs suggest something between 50 and 100. The report now holds only the slow ticks, so the cause stands out.Check garbage collection
Command/spark gcCommand/spark gcmonitorIf the spike has no clear cause in the profile, run
/spark gcfor the garbage collection history, or/spark gcmonitorto get a message each time a collection runs. A long pause at the same moment as the spike means memory, not a plugin.
Memory: a slow climb, not a spike
Command/spark healthCommand/spark health show --memoryLag that gets worse the longer the server runs, and goes away after a restart, is often memory. Run /spark health for a live report of TPS, CPU, memory and disk that updates every 10 seconds, or /spark health show --memory to print the JVM memory details to the console.
Command/spark heapsummaryCommand/spark profiler start --allocWatch the floor of the heap, not its peaks. A Java heap rises and falls as garbage is collected; a floor that keeps rising over hours is a leak. To see what is filling it, /spark heapsummary uploads a summary of what the heap holds, and /spark profiler start --alloc profiles memory allocations instead of CPU time.
Folia is different
Folia has no single Server thread. Its README says each region has its own tick loop, and those loops run in parallel on a thread pool. A profile that only follows one thread misses most of the server, so on Folia start the profiler with --thread * to track every thread:
/spark profiler start --thread * --timeout 600Then compare the region threads with each other. One region far busier than the rest is usually one place on the map, a farm or a crowd, not a plugin that slows the whole server. Folia vs Paper explains how regions split, and Folia plugins covers which plugins run there at all.
Reproduce it before you fix it
The hardest lag to fix is the kind that only happens on Saturday evening with 80 players online. A profile from that moment is worth more than a dozen from a quiet afternoon, but you cannot schedule it.
You can make the load yourself on a copy of the server. IgniteTestTool joins bots that open menus, walk, chat and build, and with spark=1 on a load run it starts the spark profiler before the run and puts the report link in its results. You get a profile of the exact load that caused the lag, and you can run the same test again after your fix to see whether MSPT went down. Load testing a server with bots covers how to set that up and read the numbers.
Before you post a profile for help
- Profile while the lag is happening, for at least a few minutes.
- Say which Paper or Folia build and Minecraft version you run, and how many players were online.
- Send the link, not a screenshot. The person helping you needs to expand the tree themselves.
- Command/spark tickmonitorIf it is a spike, say how long the slow ticks were in
/spark tickmonitorand which--only-ticks-overvalue you used.
Paper's docs point to their Discord help channel for exactly this, with a spark report in hand.
Common questions
How do I find what is causing lag on my Minecraft server?
Run /spark profiler start --timeout 600 while the server is lagging. After 10 minutes spark prints a link; open it, expand the Server thread and follow the highest percentages, or switch to the Sources view to see how much of the tick each plugin took.
Do I need to install spark on Paper?
No. Paper bundles spark since 1.21, and Paper's docs call it the preferred way to profile. The older Timings profiler is deprecated and turned off by default in 1.21.
How do I find a lag spike with spark?
Run /spark tickmonitor --threshold-tick 50 to get a message for every tick over 50 ms, then start the profiler with --only-ticks-over set below the spike, for example 100. The report then holds only the slow ticks.
What is a good MSPT for a Minecraft server?
Anything under 50. A tick has 50 ms at 20 TPS, so a server under 50 MSPT keeps up and one above it falls behind. The lower it is, the more headroom you have for more players.
How do I use spark on Folia?
Start the profiler with --thread * so it tracks every thread. Folia has no main thread; each region ticks on its own thread from a pool, so a profile of one thread misses most of the server.