Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Resolved Connection limit

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

  1. MariuszKowalczyk

    MariuszKowalczyk

    Joined:
    Nov 29, 2011
    Posts:
    301
    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:
    441
    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:
    301
    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:
    441
    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.