Photo by Benoit Beaumatin on Unsplash
Falling down the rabbit hole
2 min read
While working on ways to implement a faster and efficient data layer for Fernand (see my last post here), I (re)discovered Firebase and their real-time database called
It has a lot of features that any web developer would love, such as Authentication (with many protocols if needed, including emails for password loss, account validation, etc), Offline mode, a really fast query model, and real-time synchronized data across all the services.
The whole set resonates well with what we want at Fernand, which includes being fast (data should be loaded in milliseconds) and reliable (it should never fail).
Firebase solve a lot of these issues, and that's what pushed me to heavily consider it. With it, we won't have to worry about the database being down, slow queries, WebSocket failing, etc...
Moreover, the code required to implement is small and easy to get started, which is a great plus too.
But I'm afraid of the issues related to now having access to the database directly. I can work my way around the restrictions now (not building complex queries for instance). But if tomorrow we need to calculate the number of users based on some advanced criteria, we will have to download the database locally, and import it on another datastore (such as MongoDB) in order to run these processes. It feels cumbersome.
Another problem I'm not comfortable with is duplicate content. With a relational database, you can have the guarantee that one element won't be present twice in your database. With Firebase, there are no unique checks done, so you can have two incoming requests having the same data, and, somehow, end up with two "unique" values.
One other drawback is that I will have to rewrite the entire backend system we've implemented to now use the Firebase DB instead of MySQL. We are still small and starting, so it's not the end of the world, but what we have is working really well, and we will have to test it again with the new structure.
I agree that Firebase is incredibly fast to return data - my tests shows an average of 20ms! - But you can be the fastest in the universe, you won't be enough if your user is loading 5000 tickets with a slow 2G connection! You can't compete with that! Not even Firebase.
So here I am, pondering the pros and cons, and being quite stuck on the matter...
See you next episode for my takes on the subject!
Thanks for reading.