Lessons learnt (the hard way) using Firebase RealTime Database

Pablo A. Martínez on 2018-02-23


Last year at GreenLionSoft we decided to progressively ditch various of the goodies provided by AWS and go “all in” into the Google’s Firebase suite.

In this article I want you to learn some critical tips to avoid the errors we committed while integrating Firebase Realtime Database that resulted in a unexpected monthly bill of more than 1.000€.

Firebase Realtime Database for what?

As you probably can imagine the “RealTime Database” is a solution that stores data in the cloud and provides an easy way to sync data/state among various devices.

Up to the date we had a Spanish Transit app (Madrid Metro|Bus|Cercanías) in our portfolio that allowed users to save different kinds of “favorites” like bus stops, routes, etc… Those favorited items were saved locally in the device serialized as JSON strings. Not a big deal.

One typical complain we received, specially during Christmas when lots of new phones are given as presents, was:

“hey guys, I have a brand new phone, Is there a way to migrate my favs from my old phone to the new phone?”

So here Firebase came to the rescue, to accomplish what users were requesting we needed two things, being able to identify users and being able to store their favorites into the cloud. The deadline was set, we had to finish the implementation before the end of December 2017 (Christmas holidays)

Integrating Firebase

1. Firebase Authentication

To be able to identify users we had to integrate Firebase Auth and as our app was only available only on Android we only enabled Anonymous users and Gmail as “auth providers”.