Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Third Party Photon Pun Server Overload?

Discussion in 'Multiplayer' started by BrunoPaese, Nov 27, 2019.

  1. BrunoPaese

    BrunoPaese

    Joined:
    Mar 25, 2019
    Posts:
    3
    I'm developing a multiplayer Tower Defense mobile game with some friends using Photon. Up until a certain point in a level (after around 30 enemies have spawned) their Transform is shown seamlessly between both clients playing the game. After this point, however, the server seems to choke. Their movements look extremely laggy, whenever a player kills an enemy, it stays alive on the other client's side, and the game becomes unplayable. We don't know much about Photon so we have no clue if this has something to do with overload of the server. Calling RPC Methods constantly in the Update Method could have something to do with it? Is there a way to see if the server is getting overloaded? We're kind of in a hurry so any help would be appreciated.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,073
    Right, there is a limit of how much you should send via the network.
    With more units moving, you should spend some time to optimize how they update everyone else of what they do.

    How many units do plan to have active as maximum?
     
  3. BrunoPaese

    BrunoPaese

    Joined:
    Mar 25, 2019
    Posts:
    3
    Thanks for the reply! By units I assume you mean any object that must be syncronized with every client connected. If so, we currently have 137 enemies that spawn in 5 waves, 2 players, 2 towers (you only get two towers to defend) and their projectiles, and a coin that will teleport to a different location every time it's pick up.

    I went through every script and made sure RPC Methods weren't being called at every frame. Now they're called every x seconds and that seems to have helped (not entirely certain yet though), since the enemies are not lagging at that specific point anymore.

    I'd still like to know if there's a way to check the server's performance, just like you would with Task Manager on your computer, and/or a way to "clear" the server so that everything that has been called up to a certain point is removed from it's memory or something. Then again, there could be a more efficient way to make sure the server doesn't overload that we're not aware of.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,073
    Ow. Yes, calling RPCs evers frame won't work for sure and if it would, you wouldn't like the costs due to that.

    Actually, to sync object's positions, you could use PhotonViews. They are sent in a fixed interval anyways.
    Here's an overview:
    https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state

    The server won't be the one overloading. The clients and network are less capable than the server.
    If you just want to look into things, get the Photon Server SDK and add the counters you are interested in. A bunch of performance counters are available but not something like "how much is queued".
    https://doc.photonengine.com/en-us/onpremise/current
     
  5. BrunoPaese

    BrunoPaese

    Joined:
    Mar 25, 2019
    Posts:
    3
    Yes, we're using PhotonView to sync position, animation and rotation. Seems like the problem was indeed the thousands of RPCs being called during the match. It didn't cross our minds that it'd be a problem but it makes sense. Thanks for the tips and for helping us!