Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Connection limit

Discussion in 'Unity Transport' started by MariuszKowalczyk, Mar 23, 2023.

  1. MariuszKowalczyk

    MariuszKowalczyk

    Joined:
    Nov 29, 2011
    Posts:
    290
    Is there any limit of connections that Transport can handle per one driver? If I recall correctly UNET was limited to 65535. How does it look here?

    Also if I understand it correctly, the Queues Capacity should be set in relation to the maximum number of connections we want to handle, otherwise we will have an overflow.
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    276
    Regarding the maximum number of connections, theoretically there is no limit. Well, there's technically a limit of
    Int32.Max
    since we index connections using integers internally, but otherwise we don't impose any limit. Now, the practical limit is a different issue and will depend on your memory constraints and processing budget for the transport. We have performance tests with 500 connections and thus can attest that this works (at least to some degree), but we've never tested more than that.

    Regarding queue sizes, their size should be dictated by how many packets could be sent/received in a single update/frame. That's often related to the maximum number of connections, but the exact nature of the relation will depend on your game.

    For example a very slow-paced game might get away with using a send queue size that's a small multiple of the maximum number of connections, or perhaps even less than that if the traffic output is expected to be very low. But a more fast-paced game might require larger send queues to accommodate more traffic. As a reference, Boss Room has a maximum of 7 connections and uses queue sizes of 512 packets (mostly because when synchronizing the state at the beginning of the game or when a client late-joins, a lot of large packets will be sent in a single frame).
     
    MariuszKowalczyk likes this.
  3. MariuszKowalczyk

    MariuszKowalczyk

    Joined:
    Nov 29, 2011
    Posts:
    290
    I wonder what do you mean by "at least to some degree". Was there any problem?

    I want to minimize the usage of the CPU on the dedicated server, so I want one instance to process many games/rooms, to minimize the overhead needed when there is one instance per room. In other words I want to have one instance of the server application to have hundreds if no thousands of players connected and servicing many separated game rooms with 2 to 32 players each. Then I would run one instance per cpu core to maximally use the server processing power.

    I wonder if there is anything that will prevent me from doing so.
     
  4. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    276
    There was no problem observed. My point was that we're only testing that number of connections in the context of performance tests. That is, we're not testing the entire feature set of the package with 500 connections. So I can only claim that things work insofar as these things are part of our performance tests. For example, our performance tests do not currently use encryption, so I can't fairly make claims that 500 encrypted connections would work (I don't see why it wouldn't, but I don't have the data to back that up).
     
    MariuszKowalczyk likes this.