HLAPI has random lag spikes! Any help apprecitated!

Hi there,

After upgrading my game world which is now containing 150k trees (network instantiated) and 600 NPC’s I sometimes get network delay spikes. Which feels like if messages get paused and saved up until eventually (after 2-3 seconds) it get’s released to the client.

The trees don’t do much serialization, they just spawn with some information regarding grow percentage. And the NPC’s only get like 1 update every so second.

I have reversed the proximity checker to work for a player > object base instead of every tree checking if there are players near. So I did some optimizing already.

The thing is I really don’t know how to tackle those random spikes as we are only talking 10-15 players online.
What is the best option for me to debug this?

Are there any network settings I have to alter to reduce the lag? Cause I’m not using the network manager but instead use this to start my server:

ConnectionConfig config = new ConnectionConfig();
        config.NetworkDropThreshold = 30;
        config.AddChannel(QosType.ReliableSequenced);
         config.AddChannel(QosType.Unreliable);
        NetworkServer.Configure(config, MainController.instance.servers[server].playersmax);

        NetworkServer.Listen(MainController.instance.servers[server].port);

Only altered the network drop threshold to fix some random disconnects.

Does anyone have any thoughts?

Cheers

  1. Profile
  2. Don’t have one NetworkIdentity per tree, instead have a object class with the info you need. Then just have a sync list struct or something alike on a manager. Every NetworkIdentity has a Update loop called every frame. https://bitbucket.org/Unity-Technologies/networking/src/78ca8544bbf4e87c310ce2a9a3fc33cdad2f9bb1/Runtime/NetworkIdentity.cs?at=5.3&fileviewer=file-view-default

It seems the profiler won’t recognize UNET traffic…

What Editor version?

I have the 2017 edition

The profiler shoudl tell you the network information?

Works for me in 2017.1
https://gyazo.com/f3baeefbd7ebcb1ecf8e14250d41ddca

No both columns show zero traffic…
Network manager and network operations. Could that be because I don’t use the standard network manager?

Btw, what kind of ConnectionConfig parameters do you have in use and at what values? Thx :slight_smile:

Personally I use all the defaults. Except my channels and all of that ofcourse. But all the in depth stuff such as disconnect timeouts etc I have so far had no reason to edit for my title.

I am mainly focusing on developing the game and the network code atm. Haven’t dug to deep into that as of yet.

1 Like

What channels do you use and for what? I use only channel 0

I use Reliable Non sequenced for Game State.
Unreliable Sequenced for Movement.
Reliable Fragmentet for Text Chat
And a second Unreliable Sequenced for VoiceChat

Hmm, channels are interesting indeed…
What about: https://docs.unity3d.com/ScriptReference/Networking.QosType.StateUpdate.html for sending movement updates?

And why would you go for unreliable? Is it faster than reliable?

Edit: I meant ReliableStateUpdate for movement

Unreliable. Cause, I send movement updates at 20hz maximum. And at I don’t care if I loose a packet or two. Reliable basically resends the same packet over and over until you get a response. That’s just not needed.
And sequenced I use to prevent rubber band if they come in the wrong order. You could implement this yourself but UNET channels does it neatly by discarding the packets.

i agree with what twoten said, you might want to just have one network’d object for all your trees, and it can be smarter about syncing the data for your trees. like unless the client can see all 150k trees at the same time, you could cook up something that only updates the trees in the area the client is looking, etc.

same with the NPCs - if there’s some way you can batch them up, it will be much easier to conserve bandwidth.

especially if you’re using sync vars…actually i wouldn’t use sync vars at all for a project of that scale.

1 Like

That said, if you make a gane where you click to move around. You are better off syncing the clicks rather than the position. And that would be done reliably. It’s all about how you perform your game.

In addition, our game uses Server Authortive movement for the most part. (We have some other tricks to make our workflow easier).

Exactly, so if you need some “Update” loop running on the trees. What you could technicly do is have the Manager object have a global Update loop, That is a coroutine that spreads the work of updating all trees across frames. So that every tree only gets a update ran every x frames for example.

I will give this a thought for sure!
Btw, do you know if SyncVar updates too all clients or just observers? Cause if the proximity is not working it’s probably a LOT of messages thats causing the problem.

Only to Observers.