Coffee cup on a wooden table with the word BEGIN printed on the cup

MongoDB Realm: First impressions

August 25, 2020

I'm on a mission to rid myself of my reliance on Firebase without locking in on a service like AWS. The search led me to MongoDB Realm, which looks to be a serious contender. I've now dug a little bit deeper into Realm and have something more to say about my initial impression.

Pricing

The cost of Realm can be a bit confusing to figure out – as it can be with any cloud service. There's a free tier for Realm; however, the real cost doesn't just include Realm. There's a dependency on MongoDB Atlas to run a database cluster. Some regions offer a free tier, but MongoDB recommends against using the free tier in production. The recommendation is understandable; it's a shared server with low performance after all. However, it's not clear why the next two tiers are better (apart from the increased storage capacity).

For someone who is just getting started with MongoDB Atlas and Realm, it's not directly obvious which option to select. I would have liked some more guidance to be available on the page.

There is a pricing calculator with examples for Realm. It gives a good indication of what it will cost, but it doesn't take Atlas into account. That's a bit strange. Apart from that Realm gets a big plus for using a few different real-world examples, it makes it a lot easier to visualise the costs for someone new to Realm or cloud services in general.

Features

Realm (and the MongoDB ecosystem) offer a lot of high-grade features for app development. It's without a doubt a highly capable service which offers features like real-time, cross-platform sync, data visualisation (via Charts), search (via Atlas Search) and global clusters which allow your application – whatever it may be – to scale and grow internationally.

One of the most significant benefits with Realm is that it exposes a GraphQL API to query for data. The benefits of a widely used query language are many. Chief among those is the lowered threshold to get started since you don't need to learn a new query language or API – provided you already know GraphQL.

Compared with Firebase, the most significant relief for me personally is the ability to query for relations in one request. Rather than fetching a document and populating references in subsequent requests, you can define any relational data you need in the GraphQL query. The consequences are, of course, that you pay for the compute time on the server. So if you write complex GraphQL queries on the frontend, you pay for it somewhere else. That's a reasonable tradeoff in my mind. I'd rather have a performant system that can fetch relations on the server, than a system that forces new requests for each related document, making the user wait while your loading spinner is the only thing that moves.

Getting started documentation

There's a tutorial you can follow along with, but it falls under the same issue that plagues all tutorials: it's neither specific nor generic enough. It's good to get started with, but it only shows you how to add schemas and functions in the web interface.

I asked Twitter if it was possible to define the code locally and deploy it some other way. Amazingly the Realm Twitter account responded to me and included a link to the CLI. I appreciate that effort put in by the Realm team to respond to some random developer on Twitter.

Overall, the documentation is pretty good, and there are examples scattered throughout. However, it skips over some cases. For example, the Web SDK section that describes how to authenticate a user with email and password doesn't show how to handle user registration. I had to double back to the tutorial to find out how to register users.

Ease of use

Once you get started, it's pretty straight forward. By adopting GraphQL Realm has simplified the process substantially, and you can focus on learning how to write schemas and what you can do with custom functions.

Summary

It's still early days for me in my foray into Realm. Initially, I thought Realm would be a lot more complicated than Firebase, simply because the offering looks to be a lot more capable. But at this stage, I don't feel like that's the case at all. The team has managed to simplify the service without hampering its capabilities.

I suppose that the only real downside I've found is that there isn't a whole lot of informational content around Realm out there.

I guess I'll have to help change that.

If you want to stay up to date with my exploration of what Realm has to offer, follow me on Twitter: @BeppeKarlsson.