Gamehost

spark on a Minecraft server: how to find the source of lag

How to use spark on a Minecraft server: /spark profiler, /spark tps and /spark health, reading the report and finding the plugin, mod or farm that causes lag.

Gamehost team·5 min read·Updated:
Minecraft serverPlans from 2 GB RAM

Server ready a moment after payment. You can change the plan in the panel at any time, your world stays.

Before you start disabling plugins blindly, run spark. After a few minutes of profiling you get a link to a report that shows exactly what takes up the server's time in every tick.

What spark is and where it runs

spark is a performance profiler. Every few milliseconds it records what the server thread is doing, then builds it into a tree: what percentage of time went to entities, chunk loading, a specific plugin or mod. On top of that it measures TPS, tick time (MSPT), CPU usage, memory and garbage collector activity.

EngineWhat to do
Paper and Purpur from 1.21nothing, spark is built into the engine
older Paper and Purpur, Spigotspark plugin in the plugins folder
Fabric, Forge, NeoForgespark mod in the mods folder (server only)
Velocity, BungeeCordplugin on the proxy, command /sparkv or /sparkb

From version 1.21 Paper replaced the old Timings with spark, and Timings are switched off. If someone asks you for a "timings report", send them a spark report. On a modded server players do not need the spark mod themselves, it only has to be on the server.

You add the plugin from Plugins and the mod from Mods in the panel. Installation details are in Installing plugins.

The most important commands

Type the commands in the panel Console (without a slash) or in the game as an operator.

CommandWhat it does
/spark tpsTPS for the last few minutes, tick times and CPU load
/spark healthserver state: TPS, MSPT, CPU, memory, disk
/spark profiler startstarts profiling
/spark profiler stopstops profiling and gives you a link to the report
/spark profiler openopens a preview without stopping the profiler
/spark gcgarbage collector history
/spark heapsummarywhat is using memory (when you suspect a leak)

Useful profiler switches:

# profile for 5 minutes and stop on its own
spark profiler start --timeout 300
# only record ticks longer than 100 ms (catching lag spikes)
spark profiler start --only-ticks-over 100
# all threads, not just the main one
spark profiler start --thread *

The best report comes from the moment the lag actually happens: with a full server, not at four in the morning. Give the profiler at least 3 to 5 minutes.

Reading TPS and MSPT

The server calculates the world 20 times per second, so it has 50 ms per tick. MSPT (milliseconds per tick) tells you how much it actually uses.

  • MSPT below 50: TPS holds at 20, the server has headroom.
  • MSPT constantly above 50: TPS drops, players see blocks snapping back and delayed mobs.
  • Average fine, but a maximum of several hundred ms: single spikes. Profile with --only-ticks-over.

If TPS is 20 and players still complain about lag, it is usually ping or their own computer, not the server. More in Minecraft server lag and TPS.

Reading the report and finding the culprit

  1. Open the link from the console. The report opens in your browser on spark.lucko.me.
  2. Expand Server thread (on modded servers the main server thread is sometimes named differently). That is the one that calculates ticks.
  3. Work your way down the branches with the highest percentage. You are looking for the spot where the name of a plugin, a mod or a specific activity appears.
  4. The Sources view adds up time per plugin or mod. It is the fastest way to see whether one add-on stands out from the rest.
What you see in the reportTypical causeWhat to do
a lot of time in entity tickingmob farms, hundreds of animals, dropped itemsfind the farm, limit entities
chunk generationplayers exploring new terrainpregenerate the world
hoppers, redstonelarge sorting systems and clockstalk to the builder
the name of one plugin or moda bug or bad configuration of the add-onupdate, configure, replace
frequent, long GC pausestoo little memory or a leak/spark gc, /spark heapsummary

For terrain generation, Chunky is the best tool. If the report mostly shows GC work, read How much RAM does a Minecraft server need.

You can safely send the report link in a ticket to us or to a plugin author. It contains the list of add-ons and code snippets, not passwords or player IP addresses.

Alternatives and extras

On Paper, Purpur and modded engines spark has no serious competition today. Paper's Timings are switched off, and older modded tools (for example the /forge tps command) only show TPS per dimension, without pointing to a cause. General performance tips are in Minecraft server lag and TPS.

Console, plugin and mod installers come with every plan on our Minecraft server hosting.

FAQ

Only a little, and only while profiling. The tps and health commands cost practically nothing. You can leave the profiler running for a few minutes without players noticing.

No. Paper has spark built in from 1.21, so the /spark command works right away. You only install the separate plugin on older versions or on Spigot.

3 to 10 minutes while the lag is actually happening. A shorter report can be random, and profiling an empty server shows nothing.

Paper switched Timings off and recommends spark for diagnosing lag. A spark report contains more information than the old Timings did.

No. spark runs only on the server side. A player can have it installed to profile their own game, but the server does not need that.

Your own Minecraft server

Plans from 3.79 € a month, set up in a few minutes and managed from one panel.

See plans