Cross-Server Matchmaking Module

WARNING: This has not been tested with multiple servers as studio does not have the MessagingService enabled, HOWEVER, the logic does work in a live server and has shown to work properly. If you encounter any issues my contact info can be found at the bottom of this post!

Included:

  • Easy, comprehensive matchmaking module that can easily be expanded.

  • Commented with simplicity while highlighting key points.

  • Print status toggle to see whats going on in the console logs.

  • This module is NOT intended for production level projects in its current state

  • Demo link: Matchmaking Demo - Roblox

The module:

CHECK SOLUTION

  • This module can easily be used. To demo this module for yourself, place this CHECK SOLUTION into PlayerGui.

  • The module is NOT for production level games and is meant to act as a demo for the new MessagingService.

To initialize the module on the server, all that is needed is to require it. The module will return the two remotes that it creates, however these are not needed for the server.

Dictionary:

Included below is a list of helpful words to guide you through the language used in this product.

  • isDedicatedServer: If true, the current server is the games dedicated matchmaking host server.

  • printStatus: Toggle that allows you to switch on/off print statements to see what the module is doing on the console log.

  • matchmakingServerId: The PlaceId of the game that players will be put into when the match begins. This can be changed however you like as well as the matchmaking logic conditions.

  • serversActive: List of servers that are active. All servers will hold this list in case a re-host is needed.

  • queue: Queue of all players waiting for their match. When a re-host is needed, this queue will be lost and all servers will be notified that the queue was interrupted. This will allow you to easily tell players to rejoin the queue. Changing this to auto-queue players is discouraged because of how many queue request would be sent simultaneously. Still very possible to do however.

  • startQueue: Holds the functionality of the matchmaking system for starting matches from the queue. The logic loop is meant to be configured by yourself for your particular needs.

TO:DO

  • Add functionality to try and create a dedicated server if creation fails SEE LINE 221

  • Add functionality to retry DataStore connection if search for DedicatedServer fails SEE LINE 228

NOTES

If I missed anything let me know!
Message me on the Developer Forums or on my Twitter: x.com

114 Likes

Interesting tutorial resource, this makes one of my game ideas possible.

I’ll check it out when it’s time to implent it.

5 Likes

Interesting approach to cross-server-matchmaking, I really wish Roblox would add some sort of “universe server” that would be only one instance of a server, so it’s not a bunch of Roblox servers handling matchmaking at once.

5 Likes

Isn’t it interesting how MessagingService, despite being implemented differently to DataStoreService, could fulfil the same function?

2 Likes

DataStoreService is definitely not an efficient way of doing this, and it’s no coincidence they fulfil the same function, up until this point everyone has been using datastores, when MessagingService is much more reliable and efficient. Datastores are an extremely hacky and buggy method of communicating between servers.

5 Likes

Consider the fact that messaging service was made specifically for communications between liver servers and datastore service was not.

The service can also communicate very quickly with a recieving server picking up messages < 1 second after it was sent.

1 Like

I knew someone was gonna make a matchmaking module the moment I saw this feature come out.

If I understand correctly, this module picks one server to act as the master matchmaker and collects all the userids of players waiting to be matched?

2 Likes

True. It’s worth noting that someone could’ve implemented a third-party function library that fulfils the very same purpose and entirely utilises DataStoreService. Rate limits and latency cases may apply … but still.

I’ve tried DataStores for this approach in the past and it is completely UNUSABLE. Two big issues out of many are that the DataStore throttling that occurs basically ruins it and DataStore:GetAsync() cache makes sending data almost useless.

1 Like

Have you yet consulted UpdateAsync?

Aye; Rōblox have done good work for implementing this feature. Someday, Rōblox could allow these messages to be interacted with outside the game instance using web sockets and/or HTTP pooling. It might not be a certainty though.

1 Like

UpdateAsync has a 6 second cooldown and throttles otherwise, any game over 1000 players can make this throttle almost instantly.

7 Likes

This module has been updated! Check out the open source place file: Matchmaking Demo - Roblox

Module/code posted on this thread is now old and is currently only updated on this place file.

3 Likes

Can you explain what do you mean by production level games? I am guessing games with a high player count…?

Also since it has been updated, is it safe to use this in games with atleast 1k to 2k players? (Not like I am ever going to have this many players but just asking)

It means don’t use in a live game, it can potentially break.

I can’t give an accurate answer to your second question however after seeing countless Bug reports related to MessagingService I’d stay away from it.

1 Like

Is it ready for production use?

1 Like

Is the module ready for production use?

3 Likes

The bugs and issues came because people exceeded the 1kb data limit per request. Keep the data under 1kb, and you are good to go.

1 Like

The limit isn’t 1kB due to a bug, it is actually 976B (comfirmed by Roblox staff).

1 Like

Although a thousand bites differ somewhat from the 976B (as you mentioned, interesting post by the way!), I doubt that those few bytes (akin to a few characters in the data) were enough to trigger these “bugs”.

Thinking back at the original post I answered, I don’t know if the data limit was at fault anyway. Well, thanks for sharing that link, I’ll remember that for the future!

Yeah, the “size of message” limit didn’t cause those bugs (which are fixed by now I think).
By the way, 1kB is 1024B (at least in Roblox). :slight_smile:

1 Like