Search code examples
unity-game-enginecloudunity-cloud-build

Unity Game server hosting and scaling


Yesterday I faced an issue with Server Hosting and it showed me that I’m not really understanding how scaling is working on unity cloud, I will explain the architecture of my project and problem, so if you notice anything wrong at any level please explain it to me, as I’m newbie with the cloud.

Project

so it’s a card game that has to be played by 4 players and they play turn by turn, so I designed the project as follow :

  • game logic created with nodeJS and communication server-player is handled through socket connection
  • the server is wrapped in a docker container and uploaded to unity server hosting as the game is not that heavy, after analysing the resource needed for a container to be run without problem I found out that I can run 100 server on the machine provided by unity cloud (2 | GCP N2 Intel 2nd Gen Scalable @ 2.8 GHz | 8 GB)
  • in the fleet scaling settings I set minimum servers to 1 and max 1000 (here I thought that when 100 servers on the machine are all allocated, unity will start another machine for me as 1000 is not yet reached)
  • matchmaker linked to this fleet, once 4 players are gathered → a server is allocated

Problem

Yesterday, I got lot of players using my game, and all the 100 servers were allocated, so many players couldn’t join a server to play

how can I handle this ?


Solution

  • I figured it out ! the scaler is doing it’s job ! I just didn’t give him enough time to create new servers, and as I set minimum required servers on the fleet to 1 which means I told the scaler to wait until the machine is 99% full then you create new servers which is not good, it’s recommended to always keep 30% of needed resources available 1. so for my use-case I had to set the minimum available servers to 30 or something like this