Can anybody explain to me what’s the difference between Firebase and Realm?
When should I use Firebase or Realm??
Can anybody explain to me what’s the difference between Firebase and Realm?
TL;DR - see the bottom of the post.
Firebase is a suite of products which includes both Firebase Realtime Database and Firestore which are Online First databases that are NoSQL based. They also offer Firebase Storage, Notifications and a bunch of other products.
Firebase (databases) are very strong, scaleable, well supported databases with incredible performance. It has a large development community (and/but) is owned by Google (take that as you will). The SDK and API documentation has been some of the best I’ve come across and there’s a LOT of coding examples on Stackoverflow as well as dozens of online videos, tutorials and training courses.
Realm is an Offline First database with a similar feel to SQL in its queries but it’s more of an Object store than table based like SQL, and it’s ‘totally different’ than Firebase (NoSQL)
MongoDB Realm is the next gen product bringing Realm into a (IMO) much more mature and supported platform. It is also highly scaleable like Firebase but has a much smaller community to fall back on. The documentation is a work in progress but is a heck of a lot better than it used to be, and improving every day (thank you).
Both Realm and Firebase ‘store data’ so they could be used in many scenarios.
Neither product provides very good multi-tenant support, which has been my gripe for about 8 years now. But I know firebase has a multi-tenant product in the works. Not sure about Realm.
There is no pre-defined time or situation of when to use one or the other so the question is impossible to answer as it depends on your use case and more importantly, what YOU feel is the best for the task.
If you want a case for using one or the other, I will give you ours.
All of our projects are desktop, macOS based (a requirement) with some having a portable iOS component which is far less important.
Background: Firebase, suddenly and without any warning dropped macOS support somewhere around 5 years ago. Because of that we had to migrate to something that provided macOS Support, and Realm was that solution. (note that Firebase can run on macOS, it’s just not company supported). So the take-away is that we didn’t initially create the use case for switching to Realm, it was forced upon us. Note that we would probably still be Firebased if it wasn’t for that change - however, with MongoDB Realm, it’s really got a lot to offer.
In our case, the change forced us to re-model our data and re-think our apps from more of an online app to more offline. Because our data sets are very large, we also needed to account for the change as instead of the data being ‘in the cloud’ it was also on the device (hence the need for macOS). Takeaway: Realm apps consume more space.
Creating relationships between data in Realm was/is far ‘easier’ than in Firebase so that speeded development. However, the extra work it takes in Firebase is offset by the blistering performance it offers getting to that data. Also, Firebase Authentication is mature and rock solid. Realm is getting there.
Oh - one other use case thing; user persistence and record ‘locking’. Neither platform offers a feature similar to SQL Record Locking. Firebase Realtime Database has user persistence. I’ve ‘ranted’ about that elsewhere here on the forums but just wanted to mention it (again) as it could affect your implementation.
My suggestion is to create a simple To Do app with both platforms to get some experience and see the difference.
Again, IMO, if you are new to coding and/or don’t have any idea what ‘NoSQL’ is, you should take a good look at Realm to start with as Firebase will take quite a bit longer to wrap your brain around, and modeling your data is way different between the two.
One easy point to consider; is your app Offline First or Online First?
Realm offers offline first with a syncing component for online. Firebase is pretty much online only with a offline persistance for situations where the device temporarily looses connection.
A final note is that we feel both platforms are incredible and encourage you to investigate both, narrow down and clarify your use case then write some code.
My takeaway of working with both platforms is that Firebase and Realm have very similar concepts. However, Firebase is very coupled to Google services and technology.
It gives you limited access to your database and depend on google projects.
Realm on the other hand bases its main data store on MongoDB Atlas which is a cross cloud versatile database. With Realm you are not coupled with specific services but can integrate lots of 3rd party services including easy integration to AWS services.
Since your data is in Atlas and/or data lake you can write application with regular MongoDB drivers for many languages and may also utelize MongoDB charts to visualise your data quickly.
Realm also provide event based triggers and data robust functionality like integrating Atlas text search and Atlas data lake. It allows to take advantage of all MongoDB known crud and aggregations as well as support for transactions.
Now also offering graphql and mobile sync as mentioned.
Its fair to say I have much more experience with Realm but I tend to like its concepts better.
I was a Firebase programmer for three years before Realm Cloud came out. Firebase is a great backend as a service product, and it provides a very rich set of server side functions including Push Notifications, backend functions, and a number of authentication providers. What it lacked is a good client side data base. Any decent Firebase application has to combine the use of Realm for that purpose. The problem is that if you use Firebase along side Realm, you must write a set of translation code between the two models. Firebase sees the world as server side JSON objects, while Realm sees the world as client side Swift objects. Ultimately, the Realm data model is closer to what you actually want to program when you are writing client side. For this reason, I believe that Realm Cloud obviates the need to use Firebase.
As far as the security models are concerned, I wrote an article on Medium comparing the two of them. This article however is slightly deprecated since the release of the new MongoDB Realm product in June 2020.
Some great points!
To add some clarity to the above I would pose how different they are both conceptually and well as functionally; other than they both ‘store data’.
- Realm is offline first, Firebase online first.
- Realm is Object based storage, Firebase is NoSQL storage (totally different)
- Data structures are different
- Models (MVC) will be different
- Relationships are built differently
- How you work with your data is also different due to it being stored locally vs server
- How your data is updated/refreshed may be very different depending on implementation
Keep in mind that Google is to Firebase what MongoDB is to Realm. Google and Mongo are the parent companies that own their respective particular product. Both can be accessed in a variety of ways from multiple platforms.
Noting that Firebase is not supposed to be a client side database. It’s Online First, cloud driven which is why making a direct comparison near impossible. The takeaway here is that if you’re looking to store data locally on the device, Firebase is not for you.
Actually Realm local objects are Objective-C. Firebase doesn’t have storage objects at all! (lol) and data stored in MongoDB Realm is neither Objective-C nor swift. Aren’t we in JSON land on the server as a data store?
@Richard_Krueger thanks for the article post - I remember reading that back in the day. As you mentioned, a lot has changed since then; both platforms now offer powerful cloud functions (firebase is a bit more mature here), executing server side code and now with Cloud Firestore and MongoDB Realm, rules and security is way more flexible.
@Jay thanks for elucidating. Yes, the offline first capability is really the killer feature for MongoDB Realm. The fact that an app can work without being connected is huge. This is a form of asynchronous capability at the Internet connectivity level. I can really see this having major implications for building apps that breach the digital divide. Reliable high speed connectivity cannot be assumed, especially in developing countries.
I will add that the bigger problem with using a hybrid solution that involves Firebase as the backend server and Realm as the local object database is getting the offline-first solution implemented. So to get this working, you have set up a bunch of notification listeners on Firebase to syncrhonize cloud changes. And then on the client side, you need to set up an operation queue that pushes up your local changes to the server. The operation queue needs to block if there is no connection to the internet. And send up changes accordingly. To be frank, I never managed to really get this working properly. With MongoDB Realm on the other hand, you really don’t need to worry about his at all. As fas as the client is concerned, it is reading and writing a local database, which automagically gets synced in the background with the server copy when Internet connectivity is present. There is no translation code from JSON to Realm objects and no operation queue. For me personally, this was a huge productivity saver.
Thanks to all the Realm community for helping me on this problem, I just became an iOS developer and needed some help, all responses where great and easy to understand.
Once again big thanks to everybody!