Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Creating a Matchmaking flow for an an IO style game (MMO).

Discussion in 'Game Server Hosting' started by CM_RDX, Jun 29, 2023.

  1. CM_RDX

    CM_RDX

    Joined:
    Jan 26, 2023
    Posts:
    11
    Hello,

    For our IO style game i would like to have the following: A fleet of Multiplay servers that have no real downtime and can be joined until they are full. Perhaps closing/deallocating them after a while if the server is empty and no players have joined in a bit. The client can create a matchmaking ticket and is automatically assigned to an available server. The servers should be populated one by one, always trying trying to backfill a server that already hase some players on it.

    Currently i have defined the matchmaking rules similar to this: "Lobby Like Game Server" and am calling "ReadyServerForPlayersAsync" after the server was started.
    In the client i am creating a matchmaking ticket with CreateTicketAsync for my desired queue using the PlayerId from the anonymous login. This works for the first client as it allocates a new server instance, however once i reached the maxAvailableServers i can't connect to any more servers.

    Is there any way i can configure matchmaking so that it just creates an automatic backfill ticket without me knowing the server IP beforehand? (The issue i'm having here is that CreateBackfillTicketOptions takes an Ip as the second parameter that is not optional.) I would like to avoid implementing a load balancer or similar for the time being.

    If not what would be the best way to approach this problem.

    Thanks,
    Chris
     
  2. jackward84

    jackward84

    Joined:
    Jan 26, 2017
    Posts:
    87
    Code (CSharp):
    1.  
    2.     private async void OnAllocateAsync(MultiplayAllocation allocation)
    3.     {
    4.    
    5.         var address = $"{MultiplayService.Instance.ServerConfig.IpAddress}:{MultiplayService.Instance.ServerConfig.Port}";
    6.        ...
    7.  
    8.  
    Your backfill ticket takes the IP address from the allocation. Then, as long as you keep your backfill ticket alive, players will continue to be able to join your mega server as per the queue rules. If you do not update your backfill ticket, or do so incorrectly, players will be allocated to different servers.

    Players will not be able to join any server than the currently backfilling server(s) unless there is a valid reason they cannot be backfilled to those servers. Unfortunately, one of those rules is "the player already exists on the backfill ticket", which I currently have a thread about.
     
    Last edited: Jun 29, 2023
  3. CM_RDX

    CM_RDX

    Joined:
    Jan 26, 2023
    Posts:
    11
    Thanks for the reply :)

    Yes i got that as long as i provide the IP address i can backfill the server. But what i would like is an automatic distribution of connecting players so that i don't have to mess around with a service account fetching the IP of an allocated server instance. If that is not possible i would like to create a feature request. I'm just asking here in case i missed something :)
     
  4. jackward84

    jackward84

    Joined:
    Jan 26, 2017
    Posts:
    87
    You don't need to do any messing around with a service account to get the IP address of the server, it is provided in the MultiplayEventCallbacks.Allocate callback. You don't need to do anything outside of the game server itself. You just need to maintain the status of the backfill ticket which you do from within the game server. If 2 or more backfill servers are created then players will be distributed between those servers by the matchmaker.
     
  5. CM_RDX

    CM_RDX

    Joined:
    Jan 26, 2023
    Posts:
    11
    I see, so the IP of the server Fleet won't change at all? Even after updating the build config, scaling setting etc? Because in that case i could just always create backfill tickets.
     
  6. jackward84

    jackward84

    Joined:
    Jan 26, 2017
    Posts:
    87
    The IP address of the fleet/servers won't change on a running instance. Whether they ever change when servers go down is irrelevant because the game server itself is maintaining the backfill ticket. The IP address is available when the server is allocated, the backfill ticket dies when the server is deallocated (well, technically it dies when you stop updating/approving it, which is usually when you exit or decide to stop in a response to a deallocation). Rinse and repeat. The IP address and port won't change during that time, so the backfill ticket never needs its IP address udpating.
     
    Last edited: Jun 29, 2023