Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question [Fishnet] Hosting a lot of game rooms makes the server unresponsive

Discussion in 'Multiplayer' started by opriaionut14, May 16, 2024.

  1. opriaionut14

    opriaionut14

    Joined:
    Nov 28, 2017
    Posts:
    2
    Hello, I'm trying to make a game that will hold a lot of game sessions. I have a lobby where I put all of the players that log into the game, I match them together based on some logic and then I forward pairs of 2 players to their own individual scene/game sessions. All of the sessions will sit on the server application, and I tried to benchmark Fishnet to see how well it fares.

    I tried to create 2000 mock players, create 1000 game rooms and forward the players to their respective rooms. The memory usage doesn't seem to be that high (around 500 MB for my scenes, which aren't complex at all), but the app becomes unresponsive and crashes once it finishes creating them.

    I also tried to set a delay of 0.1s for each scene creation call, which fares better, but server still becomes unresponsive very often and for long periods of time when I host a lot of game sessions (1000+).

    And about this, I have 3 questions for whoever can help me:
    1. Does anyone know the limits of how many game sessions you can hold in parallel using Fishnet on a single server
    2. How I could make sure the server doesn't become unresponsive as more and more game rooms get created on it
    3. If Fishnet doesn't support a lot of game rooms (I would like to support at least 10000), what are some good alternatives for it that allow you to host your own server? I know how to use Photon, but that one forces you to use their servers.

    I'm using Fishnet 4.1.6 and Unity 2022.3.23f1.
    Thank you for reading this post!
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    Depends mostly on your implementation. Profile.

    Profile, then optimize.

    None. To think you can run 10,000 sessions / 20,000 players on the same server means you need to set your expectations straight.

    You can do 200 players. 2,000 is almost certainly going to be highly impractical with any available service. And extremely costly.

    At that scale, and keep in mind that a big one like WoW could never run more than 2,500 clients on the same server, you are going to have to write your own network layer / transport and a server built as a console application with no ‚game engine‘ code getting in the way. The server would merely be a database manager with game logic code.
     
    opriaionut14 likes this.
  3. opriaionut14

    opriaionut14

    Joined:
    Nov 28, 2017
    Posts:
    2

    Thank you for the reply!

    Oh okay then. My game is fairly simple, just a card game that sends network packets only at the end of the player's turn. And I wanted to make sure the server is prepared for a lot of connections (but yes, 20.000 concurrent users may be fairly unrealistic on a single server). Then I guess other games host multiple servers and forward you automatically to the best server available.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    20,000 GameObjects with a visual representation is already a framerate killer in singleplayer. Entities would help.

    But really none of this should concern you right now. Make that game what it is: a 1 vs 1 game. The whole idea of putting multiple users together in the same server requires you to work on something that game server hosting with matchmaking provides you already.

    Although turn-based 1vs1 games are not made with realtime networking frameworks but rather stateless REST services. These only require a database backend and minimal server-side scripts. Two players still need to "find" each other (matchmaking or bluetooth nearby) but then they would only need to send webrequests including their player ID and the card(s) they played.
     
    opriaionut14 likes this.
  5. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    422
    That sounds like a burden even for an offline game. If you are using separate physics scenes as well, I'm surprised you even made it that far.