Search Unity

Multi-player and multi-matches online game

Discussion in 'Multiplayer' started by wunderwuzzi, Apr 3, 2020.

  1. wunderwuzzi

    wunderwuzzi

    Joined:
    Dec 24, 2016
    Posts:
    3
    Hi everyone,

    I'm pretty new to multi-player games, and looked but haven't found a discussion around this topic, although I think it must be a common challenge... which might mean I'm not using the correct terminology, but let me explain the challenge I'm having.

    I'm working on my first multiplayer game (2 players compete in one match) and got everything working pretty nicely to host a single instance of the game using Mirror. I'm hosting my server instance on a Linux VM in AWS, pretty nice and straightforward.

    What I'm wondering now is how to best support multiple matches running at the same time (e.g. host the same room x times) to support more players. One match only has two players, but I'd like to have let's say 10 matches running at the same time.

    Is the typical solution to host a "dispatch" server game which just creates instances of the actual game (on new ports) and then matches players and redirects them to the newly created instance? Since this might be a bit of a waste of resources (like good old cgi on webservers), I was wondering if there are other design patterns using Mirror.

    Are there any programming patterns or examples to such multi-instance games this with Unity/Mirror?
    Is it possible to have multiple scenes running at the same time with Unity (server mode)?
    Whats a good way to solve this problem?

    Thanks for any suggestions or feedback,
    -- JR
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity can run multiple scenes at the same time through additive scenes, but they exist in the same world space. Unity doesn't have a straight forward way of creating multiple independent world spaces. Separate server instances would be the most direct way. A master server which manages server instances is a common approach. How efficient that is would depend on the resource requirements of your game server I suppose. You'll also find that AWS and other cloud platforms are fairly expensive for the resources and data you're allotted once you start scaling up.
     
  3. wunderwuzzi

    wunderwuzzi

    Joined:
    Dec 24, 2016
    Posts:
    3
    Thanks a lot, appreciate the response! Very helpful, yeah, so far I have been using a micro instance, which is free. According to my calculations I could support about 10-20 games at the same time with this (not a lot but its a start for testing and playing with friends). The bottleneck actually seems to be memory, but technically on the server I don't need any of the large images nor sounds, and could create a different version for the server side game to keep memory footprint much lower - which something to do regardless I'd imagine? Any other ideas to create a "lean" Unity version of the server game?
     
    Last edited: Apr 4, 2020
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    On the images and sounds on the server, you might take a look at the Headless Builder asset on the store. It replaces images and audio in your project with small dummy files for building the server build, then can put the original files back for your client build.

    https://assetstore.unity.com/packages/tools/utilities/headless-builder-108317

    I've used it a few times without issue. Though because it is actually modifying your project, make sure you back it up first or are using version control.