Search Unity

Is it a bad idea to use Unity instances as Mutliplayer Servers

Discussion in 'Multiplayer' started by davidrochin, Apr 17, 2020.

  1. davidrochin

    davidrochin

    Joined:
    Dec 17, 2015
    Posts:
    72
    I'm making a multiplayer PvP game and I'm wondering if it is a bad idea to use Unity server-side (it will be an authoritative multiplayer model). Will this increase the costs of hosting? What problems could arise with this approach?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Since I'm doing something similar, I certainly hope not ;)

    Some potential issues:

    * Using multiple Unity instances as game servers is not that efficient memory wise, since you've got a separate copy of everything your game loads in memory for each instance. You can help mitigate this by not including things like textures, audio, etc, in your server build, which aren't even needed. (and don't use original Unet, as it was notorious for preallocating basically all the memory it thought it might ever use, wasting sometimes gigabytes of memory per instance if you weren't careful with the settings)

    * It is easy to unnecessarily use more CPU than is necessary to run your game. You may not need as high a frame rate on the server as you might think you need, since it isn't actually tied to updating frames on the monitor like it is on the client. So experiment with setting Application.targetFrameRate to lower numbers than you would on the client, as well as increasing the physics timestep. I've been having good results both set to 32 FPS for example, and my game relies on server side physics. YMMV

    I'd recommend getting a minimal but functional server build of your game up and running as quickly as possible and see how it performs. Make sure you analyze it with the profiler, and see what fat you can cut. Then based on what resources it uses you can estimate what your hardware requirements will be for the number of server instances you want to support, and based on that estimate the hardware costs (hosting costs).

    Good luck!
     
    Last edited: Apr 17, 2020
    mischa2k and davidrochin like this.
  3. davidrochin

    davidrochin

    Joined:
    Dec 17, 2015
    Posts:
    72
    Thanks!