DEV Community

Cover image for Realtime Database or Cloud Firestore, when and why?
Flavien Normand for Zenika

Posted on • Updated on

Realtime Database or Cloud Firestore, when and why?

When using Firebase, wether it's for the web or mobile, you'll eventually come to this question: Should I use realtime Database (rtdb) or Cloud Firestore to store this?

In this article we're not going to find the answer, we'll find the right questions for you to get the answer.

Realtime Database

Realtime Database

Firebase Realtime Database, also known as "rtdb", is a realtime key:value database. It's very performant for small data operations and has good transactions capabilities to integrate with Cloud Functions easily. To simplify to the extreme, you can see rtdb as a big JSON where you can observe any property at any depth.


Realtime database's pricing is based on traffic, the cost being $1/GB transferred after the first 10GB (the free tier). Storage cost is also $5/GB after the first GB that's in free tier.

Cloud Firestore

Cloud Firestore

Cloud Firestore is a realtime document database, it scales very well with big amounts of data and documents, allowing stuff like indexes and querying with an easier approach than rtdb. To simplify to the extreme, it's realtime mongodb with less features.


Cloud Firestore's pricing is based on the # of operations you'll do on the database. These prices are:

  • $0.06 per 100K read (50K free)
  • $0.18 per 100k write (20K free)
  • $0.02 per 100k delete (20k free)
  • $0.18 per GB stored (1GB free)

Ok, cool, but which one to pick?

Now that we have elements about these databases, it's easier to pick one, mainly because these are designed to be cheap if properly used for that they're designed for.

For instance, store big documents that you won't update often on realtime database and your pricing will explode.

My general rules are:

  • Counters, realtime gauges and other things that need to be updated a lot should go on realtime database.
  • Larger documents should go on Firestore.
  • If it's a large document and it should be updated often, consider splitting it into what will be updated often and what won't.

Which gives us these questions when picking which database to use to store something in Firebase:

  • Is it going to be updated more than once per second? Yes: RTDB, No: Firestore
  • Is it larger than a couple of primitive fields? Yes: Firestore, No: RTDB
  • Do you need to search through your data? If yes, well Firestore but you should definitely use the algolia extension for that !


In conclusion, make sure to pick the right database for the right thing if you don't want to be one of these nightmare stories people tell you when you're talking about firebase. Big things go to Firestore, things that need frequent updates go to Realtime Database.

Top comments (0)