Advice on how to diagnose server lag?

In my game, I frequently find that the servers I play online have a lot of latency when talking to the server. I find that requests can take 1-3 seconds sometimes, as well as the chat.

My question is - how can I diagnose an issue like this? I feel that my scripts are pretty optimized but I also may be completely doing bad practices. I know it is hard to give me advice without actually seeing my code, but I would appreciate any general advice and where I can start to start finding the source of this high latency.

3 Likes

I’d suggest looking at the netgraph of some of your players and F3 in order to see if you can at least locate some sort of functonality issue to start.

1 Like

Could you send a link to your game so that we can test it? It may be an issue with your network as opposed to an issue with your game.

That being said, you should also try testing in servers with various ages (if it’s a memory-leak, a newer server would have better performance, etc.).

I strongly don’t think it’s my network, my network is very solid and this issue doesn’t happen in other games. Here is a link to my game: https://www.roblox.com/games/562271837/Turtle-Island

Thanks for the advice about testing on newer servers. Please let me know if you have any advice if you get the chance to test my game out. :slight_smile:

4 Likes

When did you notice this starting? Although I’ve had it in my game before, it got a lot worse for me on Thursday and a number of players I’ve spoken to also experienced it!

This is an issue we’re investigating. I’ve heard reports of the same thing from others. The issue isn’t anything you’ve done.

11 Likes

That being said, it is possible for a developer to flood their game with too many remote events, depending on how they are handling.

Remote events use a reliable connection protocol, meaning when an event is sent, if for some reason it fails, it is sent again. There is a limit to how many events can be handled per second, and if for some reason your Lua code triggers TOO MANY events, you can easily run into a case where you are requesting more events every second than the system can handle. If this happens, and you are firing events at a consistently high rate, you may end up in increasing your latency more and more due to the fact that every second you could be issuing more requests to the system than it can handle per second.

While I am not saying your game is doing this, because this is something that is easily achievable in Lua, make sure you see if you have any logic that fires remote events every frame.

We will definitely investigate issues on our side too.

20 Likes

Bookmarked this for myself, great insight!

Oh thank goodness. Been having a big problem with this on my game as well. I’ve been thinking it was my fault, even though I couldn’t think of any changes that’d cause it. Not to mention a server restart sometimes fixes it.

@Khanovich Would reducing the number of RemoteEvent objects cause any lag? Like, I have 25 RemoteEvents and 20 RemoteFunctions in ReplicatedStorage right now. Would it be worth changing it to just one RemoteEvent and one RemoteFunction? Or is it only the number of events being fired that matter?

1 Like

One RemoteEvent and one RemoteFunction are much worse than multiple, as stated at RDC. As far as I know, it’s only the times you fire events that matter.

2 Likes

If it helps at all, I experienced very laggy servers before in a place seemingly randomly, however when I removed code which was creating new threads a lot (with spawn() I think) I never experienced it since then.

Probably unrelated, but for anyone experiencing lag it’s worth a check if you’re unsure.

I’ve also noticed my game (server) occasionally have lag every now and then. It never occurs when I play in studio though.

1 Like

You only care about a number. When designing RemoteEvent and RemoteFunction callers you have to consider what kind of conditions you can get into that these can be called too much. For example, is it possible that 1000 of them will get randomly triggered in a single frame? Because if it is, then that is definitely a problem.

Basically if you have any loop-code that triggers remote event firings based on some criteria, you should make sure those loops can’t cause things to fire a ton all at once.

An easy way to measure how many RemoteEvents being fired is too many is to make a simple place that just fires remote events every frame, and increases the number of events fired every frame as time goes on. Once latency starts increasing, you know you’ve hit the engine’s limit.

1 Like

I don’t remember hearing this at @zeuxcg’s talk. Is this true? :worried:

[Deleted old post]
[Deleted old post]

4 Likes

This was a question during a panel Q&A IIRC? Or maybe during Q&A after my talk? It’s less efficient as @Osyris indicated since we can generally pack the information about the type of the event more tightly. Splitting events based on semantics of the call makes sense for this reason. The delta isn’t that large - if you’re using numeric ids to represent the type of the action it’s going to be pretty efficient. If you’re using human readable strings you might want to reconsider this for bandwidth reasons.

8 Likes

Ah I’ve always used numeric. Just was curious if there was any scalable issue with 100+ players all calling a single Remote Event/Function vs Multiple, or if there’s a difference between 10, 100, 1000+ invokes/fires a second to 1 event vs multiple, etc…

So since the difference is so small, there’s no entirely wrong way to setup your game with RemoteFunctions/RemoteEvents in the game tree and Invoke/Fire a second ( other than trying to be efficient with the amount of calls ).

2 Likes

Perhaps server issues are exasperating the issue? That the server issues causes more unreliable internet, failed remote events requests, and more remote event requests, which makes for more connection issues, etc

I’m also trying to diagnose my server lag issues or at least find some way to mitigate it while Roblox works out the connection issues. I noticed that my Data Throughput Rate in server stats in always maxed out at “1”. What exactly does that mean?

1 Like

A server micro profiler would really help

6 Likes