Creating match rooms with firebase and firebase-queue

351 views
Skip to first unread message

Nirmal Thacker

unread,
Feb 9, 2016, 2:44:28 PM2/9/16
to Firebase Google Group
Hi All

Im building a game where some k number of people can play, live

Im using firebase for sharing user-related data and obtaining updates from a backend nodeJS on heroku. So far so good, but I have one major requirement that I havent yet fully figured out to build using firebase and a NodeJS backend

There could be potentially a large number of users wanting a play a game. I'd like to match k of these users and assign them a unique gameroom id, where they can then 'play' . For the sake of this question we can omit what the actual 'play' is.

So I'd like to create a random set of k users and here is how Im thinking of approaching it, I'd like to know if this is a good approach or a terrible approach. I'd also like more suggestions if there is an easier way to achieve this:

 1. Live players indicate on my Firebase store that they'd like to play
    using a state variable

 2. A NodeJS backend on Heroku runs every few seconds to ensure that the system
    has a good 'mix' of players. When it runs, it uses the Firebase REST
    API[1] to pull up *all* the waiting Live players (is this a good idea?)

 3. It then sections off these live players to a Firebase Queue[2]. It does
    this by taking 1000*k live users and creating 1 task. Thus it may
    create many such tasks with 1000*k users in each task.

I'd like to add that if there was a way for a single queue worker to access multiple tasks then I would much prefer that. In that case Step 2 is pretty much not required, since the live players can add themselves to the queue and a single worker can access k of these users to match them together - is this possible with the current Firebase Queue??

 4. Queue workers pick up a task and make 1000 matches and write these
    match details in the players node in firebase

 5. Players waiting on their node are now matched with a unique gameroom
    id and k other players

Architecturally is this sound? Im not very pleased with the idea of creating large tasks on the firebase Queue , and if there was a way for a queue worker to pick up more than 1 task (so if a worker picked up k tasks at random - thats a match right there) , that would be much more preferable - Can this be possible?

  [1]: https://www.firebase.com/docs/rest/api/
  [2]: https://github.com/firebase/firebase-queue

Frank van Puffelen

unread,
Feb 9, 2016, 2:57:12 PM2/9/16
to Firebase Google Group
Reply all
Reply to author
Forward
0 new messages