Author Topic: Latency Spikes / Guidance  (Read 4242 times)

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Latency Spikes / Guidance
« on: October 11, 2017, 04:00:53 PM »
For the past while I've been attempting to set up dedicated servers for our game. I've have a server hosted on Linode, Digital Ocean and now one on NFO.

A consistent issue I've had is that latency for my players spikes rather high every 3 seconds or so. I'll get a good 3 seconds of 50ms ping (using TNets ping functionality) and then my ping will shoot up to 500ms, sometimes up to 1200ms. Then eventually it will come back down to 50ms.

This has been consistent across all these providers.... Is there any guidance or knowledge that anyone can share with me? Why might this be the case? Am I flooding the network with too many packets? Or is there possibly an issue with TNet?

I'm just not sure what to look at next and really want to get a solid / consistent online experience working for my playerbase.

Or is it really normal to have this much network jitter and game developers have just learned to deal with it?

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Latency Spikes / Guidance
« Reply #1 on: October 11, 2017, 08:56:37 PM »
Could try disabling Nagle's algorithm. Set TNManager.noDelay to true after connecting to the gameserver.

Most likely this is due to some of your code that's taking too long, though. I'd load up Unity's profiler and see if the lag spikes correspond to a spike in the profiler.
Are you using GameObject.FindXXX or loads of GetComponent<T> or a lot of Instantiate? Particularly in an RFC? Could be a million things, profiler will help narrow it down.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Latency Spikes / Guidance
« Reply #2 on: October 19, 2017, 01:52:54 AM »
If you're sending too many packets, you should see warnings in your console log such as "[TNet] Packets sent in the last second -- sent XX, received: XX".

I haven't ran into anything similar personally, even when I had over 300 clients connected when Windward first launched. Most recently I've been running a Sightseer server where I was unintentionally sending way too many packets per client and again no issues aside from the warnings in the console log. As cmifwdll suggested, I'd try running a profiler on it -- run your server from within Unity, should be easy to find the problem.