Building a Game with Meteor and RethinkDB

I really like Meteor but it has a major problem. LiveQuery doesn’t scale. The replacement, Apollo, is a long ways off. At the moment, there’s no good solution in Meteor to have the same functionality as LiveQuery but scalable.

RethinkDB sounds like a great solution. It’s a database that pushes updates to apps. It provides the same functionality as LiveQuery but does it at the database layer which can be much more performant.

There is a Meteor package for using RethinkDB but it’s incomplete. I wanted to see how well it worked though so I tried a quick test. I created two Meteor apps. One that used MongoDB and the other the RethinkDB package. Each app had a setInterval that added, updated, removed over and over. I put them both on Galaxy, scaled them to multiple instances, connected some clients and watched the cpu (not scientific at all!). The app with RethinkDB crushed the one with LiveQuery in terms of CPU usage.

Using RethinkDB with Meteor sounded promising but the existing package is outdated and incomplete.

I wanted to try quickly creating a small game for phones so I made a dots and boxes game. Ever play it on paper as a kid? I wanted to use RethinkDB but couldn’t use the existing package. Instead I simply put RethinkDB queries inside Meteor publish functions and added/updated/removed the result. It’s very simple, everything in Meteor including minimongo works the same.

Yesterday Dots and Boxes went live on the Android and IOS app store. It took 26 days to make. I wanted to learn about RethinkDB, publishing to app stores and running ads. I found I really like RethinkDB. At first the query language was very confusing but eventually found that I like it more than MongoDB’s.


RethinkDB’s query language ReQL can do if-then-else statements. This means things that are usually done on the server can instead be done in the database.

For example in Dots and Boxes for a game to be ready all players have to be ready. With MongoDB the player data would have to be fetched then checked on the server before setting the game as ready. With ReQL that can all be done in one query. Not only is it less trips between server and database it is atomic. With the example above in MongoDB it’s possible that a player could be set as ready between the time the player data was fetched and the time the game was updated. This isn’t possible with RethinkDB because it’s all one query.

ReQL is more complicated than MongoDB’s query language but it is much more powerful. This combined with it pushing updates make it a pretty awesome solution I think.

Also, check out Dots and Boxes on the Android, IOS or Chrome stores.

Like what you read? Give Daniel Phillips a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.