Search Unity

Discussion Insight about Multi Server Architecture

Discussion in 'Netcode for GameObjects' started by itisMarcii_, Aug 22, 2022.

  1. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    Hey, like the headline already asks, does anyone have insights with multi server architecture and the usage of Netcode for GameObjects?

    I wondered how flexible Netcode is to achieve such a complex structure or if there are specific obstacles which makes the implementation quite a work around. Like, how is the Server-Server communication?

    Thanks :)
     
  2. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    For people wondering how to communicate between two servers i got a solution:

    You need an extra NetworkManager that connects to Server 1, this NetworkManager works as Client and Communicator between Server 1 and Server 2. That Communicator sitzt besides Server 2 and communicates with Server 1 via CustomMessages.

    Server 2 can command the Communicator to send a custom message towards Server 1 (as Client to its Server). And Server 1 can responde to the Communicator via custom messages as well.

    Like that you dont need to spawn an extra NetworkObject (since NetworkManager cant have NetworkObjects) and just use two extra scripts (On Server 1 and on Communicator) that controlls the communication and reads the messages.

    Its a lot of extra work of communications because of the custom messages and the extra NetworkManager, but its works.
     
  3. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    Something like that:
    upload_2022-8-23_17-2-6.png
     
  4. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    660
    I'm no expert but I'm struggling to understand the diagram. Does the client disconnect from the lobby and join the game server at some point?
     
  5. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    Yes that is correct. The LobbyServer will send a message twoards the client with the Server informations (Address, Port, Passphrase) and the Client will disconnect und connect into the GameSceneServer with those informations.

    I am currently testing that method and will check how smooth you can get.
     
  6. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    660
    It's an interesting problem to think about. I prefer a hierarchical structure over a more lateral one so I would have the master server delegate down to the other servers, and maybe have another server for authentication and fetching existing player information. I guess there's many possible solutions and you've put more thought into it than I have. :)
     
  7. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    I wouldnt say that :D I just tried to make it work and thought a lateral system could be the best for my test case. I am currently trying to switch scenes/servers through a portal and I am testing how smooth you can make that jump between two servers without the client feeling the server migration.
     
  8. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    660
    It looks like the author of this thread is spinning up new instances and reconnecting clients to them so some crossover with what you're doing.