FaunaDB for real time games

I have been loving FaunaDB for various projects, especially small side projects. One thing I have been playing around with is building a simple multiplayer dice game and I have a burning question:

Will FaunaDB be a good solution for real time UI?

The good so far:

  • Concurrency is not a concern for me. FaunaDB handles concurrency well with its ACID model.
  • Scale is not a concern either, especially with players in multiple geographic locations.
  • GraphQL works great. I wired up with TypeScript types and feel confident when working on frontend UI.

The rough parts:

  • Polling: I believe GraphQL subscriptions are on the roadmap (correct me if I’m wrong) and that would make things much easier. For now I am polling to get the “real time” feel, which is probably not great for FaunaDB operation limits but it works okay.
  • Logic: Programming logical sequences in FQL is challenging. It’s possible and I’m getting by but definitely takes more time than my natural language of JavaScript.
  • Debugging: Debugging logic is challenging. With complex functions, I often need to inspect state at a certain spot. The Debug function in faunadb-fql-lib is helpful but still not as convenient as an interactive debugger or even console.log (see related thread).

I love this and think about it too.

Since you can embed arbitrary logic in UDFs you can avoid an additional server between players and only give the players access to certain functions that only work when the game state would permit it!

All those rough parts though… I do not have ways around them.

Have you seen Brecht’s post on a subscription function, using timestamps to filter for only events since the last poll?


I have! Though in my current case it makes more sense for me to fetch the current game state rather than respond to a series of events.

Not sure what you mean with ‘not great for FaunaDB operation limits but it works okay’. I think it’s fine. Streaming essentially just moves the concern from your browser/backend to a different place imho :slight_smile: but I might be seeing that too simplistic.

Thanks for the feedback though. We are aware of the Logic and Debugging part and hope to improve that significantly :slight_smile:

1 Like

@databrecht regarding operation limits:

With 5 participants polling every 2 seconds (30 r/m), a 10 minute session would result in 5 * 30 * 10 = 1500 requests. It would take just 67 sessions to reach 100K requests, the max per day on the free tier. I think you are right that this is fine. I noticed Firebase maxes out at 100 concurrent real time connections on their free tier and I assume Fauna will have a similar limit, so I’m not sure there would be a significant cost difference in the end.

1 Like

Ahh, the free-tier limit :slight_smile:.
Of course, that is not really an operation limit but it’s true that you start paying if you go beyond and when pulling every 2 seconds, you definitely get there pretty quickly. I’m not sure how our streaming (it’s coming) will be implemented but I expect it will be much cheaper in that regard.

The 100 concurrent real time connections is probably because they need to keep this connections alive which is a complexity introduced by true streaming. I’m not 100% sure yet whether we will have such a limit in our streaming implementation. In each case, there is of course no such limit with a polling approach (to my knowledge) since in that case it just behaves like an API.

Even ignoring the free tier aspect of this, it becomes expensive pretty quickly once you start getting traffic and you need to give constant updates to your users.

@databrecht do you know if subscriptions will be exclusive to GraphQL?

Since this will be a client feature I’d rather avoid adding a GraphQL client to my front end apps just for this feature.

As far as I know it won’t be exclusive and might even come out first in FQL? Not entirely sure. @summer or @lewis are the best ones to respond to that :slight_smile:


Yes, streaming will come out in FQL first, with GraphQL subscriptions shortly after. I believe the free tier will have a limit on the number of connections, but all of this is still being worked out.


Hi everyone, I’m new here, I wanted to get some news regarding the GraphQL and FQL subscriptions since I wanted to switch from Firebase to FaunaDB and just realized that FaunaDB doesn’t have a subscription feature yet. So, I’ll be following this thread and I’m looking forward to this new feature!

In the meantime, I just wanted to point out (please let me know if I’m wrong), but the 100 concurrent real time connections are when using the “Realtime Database” product, but the newer database product “Cloud Firestore” which I think is more similar to FaunaDB also allows realtime updates, but lets up to 1,000,000 maximum concurrent connections for mobile/web clients per database (https://firebase.google.com/docs/firestore/quotas). It doesn’t seem to limit the concurrent connections on the free tier more than the paid tier.


Thanks GuiB, always good to get insights of people who worked extensively with the products. There are quite some confusions when talking about Fire/store/base since people indeed use the names interchangeable and mix up the features :upside_down_face: (sometimes including me… )

For anyone interested, I just finished a game using FaunaDB GraphQL with polling. Fun little project that helped me learn a ton about FaunaDB!



Hey, can we link to the code somewhere? If so, I can add it to our list of articles/projects.

@databrecht Here is the link to the code: https://github.com/goldenshun/botwise

1 Like

Hi y’all. I’m also interested in faunadb for games with realtime data. I’m curious what the updates on this feature is. Anyone knows?

@Pjarnfelt the realtime capability is currently in preview. I was able to beta test it and it worked great. I’m not sure what the release timeline is but as soon as it’s out I think it’s going to be awesome.