20TPS but High Ping/Lag Spikes

Hello! I am running a 7GB Paper server. The server usually has a constant 20TPS streak, but whenever someone joins or teleports, their ping goes up tremendously. Sometimes, it even leads to them being timed out. I was looking at the Timings report, and it seems like Connection Handler is really high. Can someone help me find the issue?
To clarify, I don’t mind the lag from the functions, just the Connection Handler. Thank you!

https://timings.aikar.co/?id=417af95471c24315b9381e384385f7d5

Does this happen with every single player, or does it only happen when a specific player joins?

There may be hardware problems with your server. When a player connects or teleports, it loads a lot of things, so if you have a slow server (for example HDD instead of NVMe SSD) as your storage, or if you have a single-core CPU for your server, or budget CPU’s, then these things could also be a huge factor to consider.

Could you provide your server host, and which exact host plan you have?


However, if this isn’t the case and you’re positive that your server hardware specs are good, then the other reason might be hacked clients.

Disclaimer:
It may not be as likely that this is caused by hacked clients, because if everything is fine until someone teleports or joins, and this only happens for the specific player and not the whole server, I would definitely think it has something to do with the server hardware.

There are some hacked clients out there that are able to send exploit packets (essentially overflooding the server with data packets so the server can’t keep up. Similar to a DDoS attack without the actual external traffic that sends network junk packets or pings millions of times every minute like a real DDoS attack)

It can be difficult to test this though, because a player may not activate the bad packet exploit until someone else joins, which would make it look like the new player that joined is the one causing it.

So if there is actually (a) malicious player(s) in your server, then the solution would be to invest a high-end anticheat that combats this. One I can recommend is Vulcan AntiCheat which will kick players who sends an abnormal amount of packets. (You may also need to configure it a bit to test what works and what doesn’t, because no plugin is perfect, and there may be rare instances where it will be a false-positive, depending on the current server TPS, and the player’s overall connection)