How to find Minecraft server lag with spark
spark is a free profiler that records what your server spends its time on. It replaces guessing with a list you can act on.
1. Install it
Paper includes spark already. On Fabric, Forge, NeoForge or Spigot, get it from spark's download page and restart.
2. Check whether the server is really lagging
/spark tps
A server aims for 20 ticks per second, which gives each tick 50 ms. The TPS and MSPT guide explains the numbers. If TPS is 20 and ticks are well under 50 ms while players complain, the problem may be their connection or their computer, not the server tick.
3. Take a profile while the lag is happening
/spark profiler start
(wait a few minutes)
/spark profiler stopspark prints a link. The profile only knows about the time it was running, so run it during the bad period. A few minutes is better than thirty seconds.
Paste your spark link into the explainer and it reads the profile for you.
4. Short freezes need a different capture
A normal profile averages all ticks, so a rare slow tick gets diluted. The spark docs suggest two steps:
/spark tickmonitor --threshold-tick 50
/spark profiler start --only-ticks-over 100
The first shows when slow ticks happen. The second records only ticks over 100 ms, so choose a number below the length of your spikes. Source: spark docs.
5. If you can't upload
Add --save-to-file to the stop command and spark writes a .sparkprofile file instead of uploading. You can open that file on the explainer page too, and it stays on your device.
Before you share a link
Anyone with the link can open it, and spark keeps uploads for 90 days. A profile can hold your plugin list, JVM flags, the name of whoever ran the command, and server config. spark filters known sensitive settings, but custom values can remain. Source: spark's privacy page.