Search Unity

Master Server behaviour and limits

Discussion in 'Multiplayer' started by madks13, Mar 11, 2017.

  1. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Hello,

    i have a game that currently is solo only. I want to implement a multiplayer mode with master server architecture.

    I want this because my game is a side-view sandbox game with tile-based proceduraly generated worlds (closest looking game is Starbound). The only thing the master server would be needed for is to keep a save of the game's worlds and their states so that each player could access them and change them, without the need of a host client always being online. Also, i think about adding a chat system which would go trough the server, and i might add some other features that require a system with a host.

    Now, the idea i had was to keep the responsibility of the server to the minimum : get/put commands for changes in the world, say/whisper/shout... commands for the chat. Everything else, physics, interactions, missions/quests... would be managed by clients.

    I know this could potentially lead to cheating (items copying, commands spoofing...). The reason i'm writing in here is because i don't have much of experience in multiplayer game architecture and would like to ask a few questions about my situation explained above :

    - If i add some anti cheat system on the server or the client, would that be enough to discourage cheating on most servers?
    - Does the system i explained above have some major flaws that could create bad experience for players?
    - Is there an alternative solution to my needs that might be better?
     
  2. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    - No. ANY anti-cheat client-side will always be defeated.
    - Yes. The server exist for authority. Stripping authority away from the server defeats the purpose.
    - Yes. Re-consider the role of the server and client.
     
  3. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Well, the problem is that based on what i've seen up till now, a client+host system would require too much resources from any VPS to be able to support the server. I've seen the Conan Exiles server and it requires quite a lot of resources for a finite, non generated world. How would i benefit from using the popular approach for the master server architecture?
     
    Last edited: Mar 11, 2017
  4. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    It is super dependent on what you're doing, and it's hard to tell exactly what you need, but look at how Terraria and Minecraft servers are setup. You never, ever, trust the client. Everything must be authed through the server.
     
  5. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Hello,

    first of all : i'd very much like to check out the source code of Minecraft and Terraria, but i don't think the owners will allow us to get our hands on it.

    That said, i appologize if i didn't give enough details. Below you can find an image representing what i'm trying to get to. Network.png

    Basically, there is a master server containing a list of all game servers (official servers, private servers, local servers). Clients connect to it to choose and connect to a game server they want (disconnecting from the master server of course). Once they are connected to the game server, the data on the world is on the game server, which is sent to them as they need it (enough to load a scene and play). Everything about the game world is kept on the game server, which allows players to play asynchronously.

    I hope this explanation was better.

    The reason i want the game server to be minimalistic is because i don't yet understand how the ruling would be done over complex things such a physics. The obvious solution to me is that the game server will have to load, for each client, it's immediate environment and do the math itself. And this is not something i think any server can handle.

    I'm saying this because the only experience i have is a multiplayer game with a master server architecture with a chess-board like world and no physics, so it was easy to let the server do most of the calculations. But this game has a lot more features, so i'm not seiing a way to do this properly.
     
  6. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Bump?
     
  7. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you have the Game Servers host the simulation with authority, they do all the physics. Clients give commands on what they would like their character to do, but ultimately the Game Server decides. If the game is fast moving you may need to include a level of client side prediction as well.

    Doing it that way significantly reduces cheats, but it also increases hosting costs to you since you're going to have to host every Game Server yourself. If you offload this onto client machines you reduce your hosting costs, but will have to accept that if your game gets any level of popularity that there will be significant cheating.
     
  8. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Well, as i said, i don't really mind having the GameServer being the authority. However, given the nature of the game, i don't see how i could make a server that doesn't require top of the line GPU performance in order to be able to host 32 players.

    As i said, given my understanding on how the MasterServer system works from the tutorials, i think i would need quite a number of objects in the GameServer scene in order to be able to manage the physics for each player. And when i try to do that on my computer with an actual graphic card (a GTX 970 M), it freezes at simple instantiation of the tiles prefabs, which do not have any texture applied, only colliders.

    So unless i misunderstood how this system should work, i only see one option left beside moving the decision making to the client side : forgoing the Unity3D physics and coding my own in order to reduce the burden on the GameServer to a minimum. But then there is not much reason for me to keep Unity, given physics and multiplatforming is the main reasons the game is made with Unity. And this is why i hope i misunderstood something.
     
  9. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Why are you trying to render like a client on your server? You shouldn't need to render anything. Just build it as a headless Linux build and launch it via command line. No graphics hardware needed. You can also on Win/Mac try the -batchmode -nographics command line options.
     
    Last edited: Mar 28, 2017
  10. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    If you've already read my post before this edit, please disregard it. It was written in haste right before i went out.

    I've already seen mention of those options before, however, since i haven't made a multiplayer game before i haven't connected it to my case.

    Since that was mentioned, i got new questions about how that works but i will save them for after i've read up more on that.. Is there documentation that clearly explains the inner workings of Unity3D when used with those?

    Edit : after doing some brief research, i've seen mention that those commands are usable only with Unity Pro...which i don't have. I'm using Unity free version. Does that mean i would need to buy Unity Pro or subscribe for 12 months in order to be able to continue my project?
     
    Last edited: Mar 28, 2017
  11. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I think you're looking at unity 4 licensing limitations, which changed with 5.
     
  12. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Well the discussion i saw that in was old, so i suppose it could have changed in the mean time. I haven't yet had the time to try it out myself.

    Also, i found some time to find and read documentation on multiplayer using UNET. I'm begining to understand the basics, however there is one thing i wanted to add later on in the game but don't yet see how to do : players in separate scenes.

    What i mean by that is that i thought about placing portals, or doors that would bring the player entering it to another map. However, given that the requirement seems to be all players on the server inside the same scene, the only way i see is placing the secondary maps around the main map and doing coordinates transformation and moving players between those maps. Is there a way for a server to place some players inside one scene, and others inside another scene at same time?
     
  13. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The server can only run the simulation for a single scene at a time. I've heard of some people designing their server so they have different maps loaded in the same scene but located far enough away so as to not be seen by other players. For example stacking the map areas vertically far enough away to be beyond the player camera's far clipping plane. By default though you're then sending updates to all connected players of all players, even ones not in the same map area.

    The way I'm handling this for a game I'm making is to have every map area a separate scene, and every scene a separate server instance. Multiple server instances can be run headless on the same server hardware. When the player crosses the boundary between scenes they are disconnected from one server instance and connected to another.
     
    Last edited: Mar 29, 2017
  14. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    I see. I thought of using the multiple instances too, but then some questions poped up about performance :
    - How many instances can a private server have before it's overburdened?
    - Does that mean that there will be a limit to the number of maps in the game?
    - What happens if someone disregards the map limit and the server finds itself with too many instances on it?
    - How do you save changes on the same file?
    - Do you save changes on the same file?

    There are many more questions that come to mind regarding having one instance handle one map inside a world. I would be very interested, for learning purpose to know your thoughts on this. Given that i find the time, i might even try it myself. But for now i think i will do as you described nicely : multiple maps in the same scene. It's actually quite easy to do.
     
  15. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Given the subject of this post, there is one other subject i want to talk about : plugins.

    Currently all my maps are in the plugins form. I make them in a separate project, put them inside an assetsbundle and then load them when the game is launched. Given that each spawned object seems to need a net identity, is there a way to keep my plugin system while using Unity's UNET?

    I've thought about making a part that at client connection will talk with the client to see if they have all the plugins the server is using and, if not, send it to them (since it's an asset bundle it's easy to get it). Once the client gets the plugins, it loads them and then they can begin playing. Is this system possible with Unity?
     
  16. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    How many instances a server can handle depends on the resources of the server itself (CPU, memory, and network connection mainly), and how demanding your server software is on the server. You're going to end up with a maximum number of connected players and server instances that can run on your private server, but your game could use multiple private servers.

    Generally if you're doing a dedicated server setup that you're hosting yourself, you wouldn't allow players to launch their own servers on your hardware directly. If you did, you'd have a master server that launches and manages the server instances to prevent overloading your private server.

    If your questions about file access is regarding recording player inventories, accounts, etc, generally you'd use a database that all the servers would access.
     
  17. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Well, the instance solution is nice but would take some time to implement if there isn't an out of the box solution ready to use.

    As for having all the players inside the same scene producing a huge amount of information flux, it would be so with 1 map already, so N maps is no difference unless you load the whole map for each map. Given that my maps sizes range anywhere from 7k to 65k in width and around 2048 tiles in height, it is too much tiles to load in a single scene. What i do is load only the relevant part of the map for each player. This way, for each playe only an area of 200 x 200 tiles is loaded around the player. This way no matter the map it always uses the same amount of information (give or take a few movable objects).

    Also, if anyone has an answer to my question about plugins, please do write it in here.
     
  18. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Another Bump?