currently im working on a godot-powered multiplayer game with dedicated server. One Lobby contains a certain amount of players (lets say 4). The goal is to create a new server instance every time a new players tries to find a game. I thought about creating a new server instance at a diffrent port but this seems to be a dirty solution. I also considered having just one instance calcualting every player and assign them to games by id. Seems to be dirty as well. I have not that much knowledge about either networking or common hosting tricks so I'm open for any advices. Thanks alot!
ps. sry for my poor english :p
I thought about creating a new server instance at a diffrent port but this seems to be a dirty solution.
It may seem like a poor solution at first, but it's actually quite common in practice and can work very well. To achieve this with a fixed amount of servers, you can write a shell script that starts and controls N server instances. Godot dedicated servers require relatively little RAM, so this should be a viable solution as soon as you have 4 GB of RAM or more. Of course, the faster the CPU and the more RAM you have, the more instances you can run on a given machine.
However, if you need the number of servers to scale as traffic increases, it can get much more involved. You could set up a REST API that starts a new server instance when it's queried, but you need to secure it so a single client can't request too many servers and make everything slow down or crash. The server program will need to be modified to close once all clients have left the server. You'll also need to limit the maximum number of instances that can be running at a given time somehow.
Alternatively, you could look into solutions such as Kubernetes, but the learning curve can be steep for someone who hasn't played around with containers and DevOps yet.