Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question A simple example of a server for linux

Discussion in 'Multiplayer' started by ankofl_dev, Jun 3, 2024.

  1. ankofl_dev

    ankofl_dev

    Joined:
    Nov 23, 2022
    Posts:
    31
    Please excuse me, I think this is a very stupid question, nevertheless: I cannot create a roadmap for deploying a simple Unity server on a dedicated server running Ubuntu OS.

    I have already learned how to deploy a similar client-server application based on Net.8 (a simple TCP Chat with connecting clients, receiving and sending messages), but so far I have no idea how to deploy an application with a similar functionality, only based on Unity-Linux-Dedicated.

    I would appreciate any help!
     
  2. GabrielEdgegap

    GabrielEdgegap

    Joined:
    Feb 24, 2024
    Posts:
    13
    Have you looked at containerizing your game server? Using something like Docker automates the process, and then you can deploy it on any hosting platform?

    At Edgegap, we built a plugin to automate both the containerization process, and automatically uploading it to our platform so it's hosted and managed. All directly from Unity's editor.

    GitHub with the plugin: https://github.com/edgegap/edgegap-unity-plugin

    Tutorial is here:
     
    ankofl_dev likes this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,052
    What do you mean by that?

    In Unity, you have Dedicated Server as a build target and you can build for Linux (among others).
    This executable you can then upload to a game server hosting service.

    And then there's build automation where you can do the building and live updating all from within the cloud.
     
    ankofl_dev likes this.
  4. ankofl_dev

    ankofl_dev

    Joined:
    Nov 23, 2022
    Posts:
    31

    Thanks for the answers!
    Today I was very pleasantly surprised that by slightly rebuilding the project, replacing the async method with carutins, everything worked almost unchanged on the ubuntu server. Today I made a small test project, in fact only transport (TcpClient) was in it, tomorrow I will try to use this transport for the entire main project.

    I still know very little about [NetCode], and have little idea only about Rpc methods and NetworkVariable. Does NetCode have built-in support for something like TcpClient?

    Rpc can handle calling functions with a small number of arguments, NetworkVariable is suitable for synchronizing some common parameters, and what is the best way directly in [NetCode] for transferring some relatively large files between the client and the server?

    By large I mean from 1mB to 30Mb of json
     
  5. ankofl_dev

    ankofl_dev

    Joined:
    Nov 23, 2022
    Posts:
    31
    Thanks for the answers!

    By the way, can I see some sample NetCode performance tests somewhere? Just to at least roughly understand what he is capable of, and what should not be expected from him
     
  6. GabrielEdgegap

    GabrielEdgegap

    Joined:
    Feb 24, 2024
    Posts:
    13
    Containers don't introduce latency. You can read a bit about Docker/containers in this blog: https://edgegap.com/blog/dockers-for-multiplayer-game-servers

    As for netcode to transport data to the game servers, you can use any with Edgegap. We also have a small guide on which are the easiest netcode to use on Edgegap: https://edgegap.com/blog/easiest-unity-netcode-for-game-developers

    Whichever netcode you use (e.g., Unity's NGO, Mirror, Fish-Net, Photon), we have documentation to help you add Edgegap for game server's hosting: https://edgegap.com/resources/integrations#netcodes-authoritative
     
  7. ankofl_dev

    ankofl_dev

    Joined:
    Nov 23, 2022
    Posts:
    31
    Thanks for the interesting article about using Docker in Unity!

    I think the main reason for using Docker is to save money on proper management of computing power.
    At the moment, I use the cheapest dedicated server for $11 per month, its configuration:
    2x2.2GHz, 2GB RAM, 1IP
    20GB SSD RAID

    I think at this stage I would like to know the maximum allowable performance over a long period of time for this configuration without using Docker, so that I can assess the economic benefits and feasibility of using Docker
     
  8. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,052
    30 Mb Json => gzip compress it. If it's still several MB after that it is best NOT to share such large files with Netcode but use any other means of sharing files, be it your own webserver or cloud drive/services.

    And consider whether this actually has to be shared - quite often devs try to share things over the network that would only require very little information and the rest can be reconstructed from that. Typical example would be sharing a texture available on the net or procedurally, rather than sending the entire texture one would either send the URL to download the texture or send enough information (possibly just the random seed) to generate the same data on every client.
     
    GabrielEdgegap and ankofl_dev like this.
  9. ankofl_dev

    ankofl_dev

    Joined:
    Nov 23, 2022
    Posts:
    31
    In this case, I'm talking about sending the client a list of current objects on the map from the server (not their Mesh grid, but just Transform data and some of their variable values).

    In addition, 30mB is rather a maximum with a margin, usually it is about 0.5-3mB

    Perhaps there is a better way to transfer data about the currently involved objects?

    Thanks!