Server Queue / server finder system

How would I make a server queue system? Like you press a button and it searches for servers, as seen in other games such as dead by daylight, fortnite, etc. It seems that nobody is clear on how to do this and only matchmaking (host creates a lobby, invites players)

This is an interesting question.
Several methods can be used for this system such as HTTP requests, web sockets… I’m planning something similar to do via websockets (bidirectional real-time communication).

Each instance of the dedicated server “register” itself on map load into MySQL database with the following data: current players, countdown timer, min. player to start countdown, round started etc.
So basically when I start dedicated server it fills database in memory table for game list. When player click Play button he will send request via websockets to find free server (where round is not started yet for example) and also it can be based on client geoIP locations. Master server will return first free server from the database (IP and Port) and client will simply connect.

If there’s no free servers (all matches are in progress) server will put client on queue list (into database). Client will periodically checks (every few seconds) for queue list and free servers. Client will wait until server return IP and port of free server (or cancel which will remove him from queue list). Note that you need to implement some kind of timeout so it won’t fill the database with clients on queue list who disconnects or got connection error during wait time.

On gameplay…when round is started server will update the field “RoundStarted” in the database so it won’t appears in the gamelist. When match ends, server will simply delete record (or update), restart the map (which will again insert data into memory table).

Invite system could work similiar like this (if you want your own invite system). Client will send invite, it will be stored into database, and friend who is invited will get notification about it (and it can work in real-time without polling). Client who sent invite is basically host (not sure about this, but I think it will work just fine). So when all invited players join the lobby and host press Play button, he will send information via websockets about all players (so server will know about team players) and return them all the same IP : port. Of course there are many more checks/validations that have to be done to make this work properly. This is just basic example.

1 Like