In my game, I and other players in the same server have been experiencing very high levels of ping, spiking all the way into the thousands. I also see a massive amount of data being sent per second through the Performance Stats whenever a customer is served. When a customer is served, my pathfinder algorithm runs on the server to generate a path. It’s worth noting this is a custom A* pathfinder, however, it has been optimised and runs quite efficiently, taking around 0.014 seconds on average to generate a path.
My NPCs are generated on the server, but I move them on the client. I do this by encoding the path nodes table into JSON and I insert a StringValue into the NPC on the server. This is then seen by the client and the client decodes the JSON and loops over the nodes table, moving the character. As you can see, when this happens, network receive increases greatly and so does the ping. At its worst, over 25,000 KB/s were being sent, however, usually it goes to around 1000 KB/s.
When the pathfinder script was disabled, and I instead set the NPCs to simply teleport to their destination, this issue went away.
As you can see in this image, ping spiked to 42,217 and total data KB/s reached around 1000KB/s.
I’m guessing the table is simply too big in size. Can you show what exactly is being encoded into JSON/how? We might be able to suggest some optimizations.
Did the ping spikes start happening recently? Also, why are you encoding it to JSON? I feel like it could end up taking more space than just an array of Vector3s.
Well, to be honest, I never knew about them happening because most of the time I test my game in Studio and it’s fine. But, since recently I started to test my game with other players in BETA, and also stress testing it, players were reporting ping spikes, which was when I realised what was happening. So I am going to say no, I believe they have been happening for a while, I just haven’t realised.
I am putting it into JSON because that is the only way I can put it into one single value which can be read by a client. Otherwise I would have to use 30 vector3values for that same path.
Well then have you considered using events and parsing it through that way? Not the most efficient by far but at least see if that’s why this is happening
I feel like this is a performance issue instead of a networking issue, where the server freezes, the packets build up, and then it unfreezes and a ton of packets get sent to everybody. Have you tried checking for high script memory/CPU usage from the dev console?
I’m not sure why this happens, you can probably try any alternatives? I’m kinda new to the Dev platform so that’s all I can comment (A fan of AlvinBlox btw lol)
I do have to agree with you, this has been a suspicion of mine also - because the ridiculous amounts of 80k indicates more towards a packet buildup in the queue rather than network lag