Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Benchmarking connections in a Headless server

Discussion in 'NetCode for ECS' started by Opeth001, Nov 27, 2023.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,112
    Hello,

    I'm interested in determining the maximum number of game sessions that can be hosted on a single server instance. Currently, a major challenge is simulating network connections to evaluate the performance of my game's headless server. For bandwidth, I can estimate it by multiplying the consumption from a single connection by the number of players. However, gauging CPU and memory usage is more complex.

    My question is: Is there an efficient method to estimate or simulate CPU and memory usage for a given number of players without establishing real connections?
    I'm curious about Thin Clients, but this feature lack of documentation makes it difficult to know if its suitability for my needs.

    Edit:


    Also, it would be amazing if you provide any other advice regarding Headless Servers.

    Thank you.
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    873
    Thin clients are the way to perform load testing and for benchmarking the server with clients that actually connect.
    The server will see them as normal clients, so data will be sent to them and processing of the entities will be carried as normal.
    Thin clients, from their end, have no presentation, nor process any ghost data. End results: they only send input to the server (random, because they lack context to do anything better, apart recording the input itself) and they can read and handle rpc.
    So a way to do that would be to make a server build, and use the editor to spawn thin-clients (or use a build where you just create thin clients) and let them connect to the server.

    However, a real connection is still made. I would say that connection is still part of the CPU cost and should be considered. There is a cost due to the processing of many connections that while not big, it is still large enough.
    Not to speak, having a connection is necessary to make the server send data (that is usually one of the the largest cost).

    In case you need to make a build with multiple thin-clients (but no client) you can write your custom bootstrap for that and hang a build that spawn up to N thin per process, making affectingly this test pretty fast. The annoying bit: you still need to make build. However, and that the point, because of the missing visual and the fact there is little processing, for that one specifically you can:
    1) remove all shader compilation
    2) avoid using burst (because probably not necessary)

    That would speed up the build significantly.
     
    Opeth001 and WAYNGames like this.
  3. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,112
    thanks again for your reactivity :)

    is there any sample to demonstrate how to create thin Clients and to fake the inputs ?
     
  4. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    974
    From you bootstrap method call the
    CreateThinClientWorld
    from
    ClientServerBootstrap
    .
    Then connect the thin client to your server.
    Repeat the operation has many time as you want Thin Clients.
    Then make a system that has the
    [WorldSystemFilter(WorldSystemFilterFlags.ThinClientSimulation)]
    attribute and in that system set you input component for the thin client.
     
    Opeth001 likes this.
  5. SamuelBellomoUnity

    SamuelBellomoUnity

    Unity Technologies

    Joined:
    Sep 24, 2020
    Posts:
    8
    Netcode has a bunch of samples here
    There's one in particular for thin clients here
     
    Opeth001 likes this.
  6. jmgek

    jmgek

    Joined:
    Dec 9, 2012
    Posts:
    96
    Not to hijack the form, Would someone be able to give a quick rundown of what they were able to achieve?. I just like to know if ECS net code is better than another framework, let's say like mirror.
    , Before committing to a full day of testing of the netcode that code.
    And what I would be seeing in comparison.
     
  7. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    286
    We publicly state 100+ players comfortably (see https://create.unity.com/megacity-metro), but our teams expectation is higher (depending on use-case and hardware). The problem is that, at these kinds of scales, it quickly becomes optimization-specific, and thus game-specific, which is why we haven't currently released any CCU benchmarks.

    One gotcha with Netcode for Entities is that we default our Netcode settings to an aggressive, bandwidth & CPU-intensive strategy (1 snapshot per player per tick @ 60Hz, ~1400 bytes each, and every ghost is considered important enough to be added every frame). It is necessary to tweak these settings for a game attempting to reach 100+ player CCUs. See the optimizations doc page for details of where & how you can make significant improvements without impacting gameplay quality.
     
    Opeth001 and jmgek like this.