How can i make a Scalable and Reliable Global Matchmaking System?

Hello, I apologize in advance for my bad english, I hope I will be able to explain myself correctly.

In the past few days, I’ve been trying to figure out how to make a global matchmaking system, where lobbies with 1 to 4 players connect each other to start a 40 players game.

So far, my ideas and their problems are as follows:

Idea 1: MessagingService: I thought that I could try to make a Peer-to-Peer matchmaking system making it so when a player tries to start a game and there is currently no other matchmaking or if all of the matchmaking servers are full, the player’s server becomes a “Master” server and starts gathering all of the other future requests from other servers until the matchmaking is full, and then starts the game’s server.
Problems: I don’t really know how to manage a “Master” server closing. If the “Master” server leaves the matchmaking, who would the matchmaking ownership go to? How can I be sure that the new owner is still in the matchmaking and won’t leave as the message is being sent? Also, apparently, the MessagingService is not reliable, or at least that’s what many developers are saying

Idea 2: DataStores I could use the same methods used to create ServerLists, just with matchmaking. This way I would have a list of all open matchmakings and be able to make players join them
Problems: Who should run the code to create the server? I could update everyone once the player count reaches the threshold, but how can I update a datastore this fast? And what if there is 1 slot left and 2 players place themselves inside of the matchmaking at the same time? How can I check to make sure that one player is outside of the bounds of the matchmaking lobby? DataStore:OnUpdate() was deprecated but I really don’t see how a Peer-to-Peer system like MessagingService can be a good alternative, they work in such different ways!

Idea 3: Big games The last option is to create 100 players games and hope that at least 40 will join the server-sided matchmaking and won’t just go afk
Problems: The problem here is clear, if too many players go afk in a lobby, 39 players will get stuck. Not only that, but it would also limit a lot the ability to create parties with your friends! If i make it so the game only fills 50 slots by itself, then the probability of players getting stuck will get higher, but if i make it so the server gets filled, people can’t create parties

As you can’t see there doesn’t seem to be a clear “Best path” to follow. All of them have game-breaking problems and I really don’t know where to go from here.
Keep in mind that I need the system to be scalable. The game I’m working on expects anywhere from 15000 to 50000 players online on the release date, so I can’t create my own Node.JS server and expect it to survive. I don’t even have the funds to keep a server capable of managing such a wave of players open.

Please help me find a solution, I’m desperate

2 Likes

MessagingService used to be a pretty solid means of server to server communication but a few weeks after it got released they changed the rates of it and can only handle about 1 message every 3 seconds if you have a large player count. For fast updates this is not sufficient to keep up with that.

Datastores are meant for storing data not for communication between servers. Datastores will work but there will be more than 30 seconds delay between servers which is not good for a global match making system.

There is a 4th option you can do (I also use this method) which is using httpservice and having your own server. The good thing about using httpservice is that you can send so many requests a min, 500 requests per minute if I remember correctly. The delay time to communicate is less than 1-2 seconds but it can scale pretty well and is reliable provided that the server is up. If you are interested in using httpservice I can help you as I have done many servers like this for my games.

2 Likes

Do you think an external server could manage 50000 players requesting to join? What would be the costs connected to keeping such a server open? I’d love to speak with you to learn about this approach.

1 Like

It depends on how much data you want to send. If it is just basic player data for the match making system you could probably scale it up to a huge amount. If you can tell me what else you need the server for besides the matchmaking system I could come up with a better rough estimate if it is feasible for you. Currently my server is running is managing with 500 concurrent players while barely using up any of its resources.

1 Like

This is for the people coming to this post in the future:

What I’m going to do is create a Node.JS app and upload it on glitch.com using a membership VPS, this should be able to maintain about 80k people requesting an update on their matchmaking every second at the same time (This is considering the player having a 30 bytes UserID, which usually is 10 characters, but you never know what can go wrong)

The server code will do something like this:

Roblox: SET RequestMatchmakingState(Player.UserID) --Sends max 30 bytes
Server: PlacePlayerInAMatch --If the player is not in a match
Server: ANSWER MatchPlayerCount or ReservedServerID --Sends about 30 bytes in the worst case

And then depending on what the situation is, the server can require one of the players to start the Reserved Server and notify all other players to teleport there using an ANSWER.
Players will be required to send a request every 5 seconds or they will be kicked from the matchmaking. Players who leave willingly by leaving the server or the queue will send a SET to make sure the server knows instantly.

The only possible problem with this is that the game could start with fewer players than the maximum if a Roblox server crashes less than 5 seconds before the match started, but that creates no problem, as I expect kids to leave the game as they join anyway.

I hope this will help someone, the other resources on this topic are very scarce, but I’m sure that on glitch or other services you can get a free VPS if your game doesn’t have the same scale as mine does.
As of 14/10/2020 (The date of this post) this is the only reliable way to make a sustainable global matchmaking, in the future it may be possible to use Universe Scripts if they ever come out.

In regards making the Node.JS app, I suggest you use google to research that, or search on the forum for more resources. You’ll have to learn JavaScript, it’s not super complicated, I’m sure you’ll figure that out. Good luck!

1 Like

Oh I forgot to link my tutorial

Sorry to bring this topic back from the dead, but do you think the newly released MemoryStoreService to be a good alternative to managing your own server and sending HTTP requests to it?
Or are there still things that are much better with having your own server versus using MemoryStoreService?

Memory Stores are definitely an upgrade that can work nicely with messagingservice but personally, I still believe that having your own server would be more beneficial. My argument for this is that you would be able to have a top-level server that would be able to manage everything which is difficult to do with messagingservice because servers are communicating with other servers and there is no central authority to manage the flow of data. It is still possible to do it with messagingservice but having your own HTTP server gives you way more features.

I have personally expanded upon the server I currently use for my game and am able to connect user’s in game data to my discord bot. This allows me to auto role them or give them rewards automatically in game once they verify their roblox username in my server. Stuff like this you cannot do with messagingservice.

1 Like

From my understanding, MemoryStoreService DOES provide a central authority that roblox has been lacking with MessagingService. With this you can be guaranteed a server architecture that every other server can talk to very quickly 1-1 (without contacting other servers) much faster than with datastores. I did a quick implementation of a global playercount with MemoryStoreService and it seems to do the job of what I wanted.
At the same time I do agree that even this architecture is limiting compared to a well made custom authority server that communicates with https, but that requires the obvious self-maintenance and scaling that you need to provide. So that’s why I would still prefer in-house solutions as long as they get the job done.

1 Like