Search Unity

HLAPI has random lag spikes! Any help apprecitated!

Discussion in 'Multiplayer' started by Royall, Jul 21, 2017.

  1. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    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:

    Code (CSharp):
    1. ConnectionConfig config = new ConnectionConfig();
    2.         config.NetworkDropThreshold = 30;
    3.         config.AddChannel(QosType.ReliableSequenced);
    4.          config.AddChannel(QosType.Unreliable);
    5.         NetworkServer.Configure(config, MainController.instance.servers[server].playersmax);
    6.  
    7.         NetworkServer.Listen(MainController.instance.servers[server].port);
    Only altered the network drop threshold to fix some random disconnects.

    Does anyone have any thoughts?

    Cheers
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    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-Technol...entity.cs?at=5.3&fileviewer=file-view-default
     
  3. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    What Editor version?
     
  5. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    I have the 2017 edition
     
  6. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
  7. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    No both columns show zero traffic...
    Network manager and network operations. Could that be because I don't use the standard network manager?
     
  8. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
  9. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    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.
     
    Deleted User likes this.
  10. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    What channels do you use and for what? I use only channel 0
     
  11. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I use Reliable Non sequenced for Game State.
    Unreliable Sequenced for Movement.
    Reliable Fragmentet for Text Chat
    And a second Unreliable Sequenced for VoiceChat
     
  12. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    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
     
    Last edited: Jul 22, 2017
  13. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    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.
     
  14. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    244
    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.
     
    TwoTen likes this.
  15. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    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).
     
  16. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    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.
     
  17. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    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.
     
  18. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Only to Observers.