Realtime-Database Vs Cloud-Firestore?

Today, I was attending at Google Developer Day Extended at FYI Center in Bangkok Thailand. Thank you GDG Thailand & Jirawatee 🔥 for firebase session

Most of developers, I know so confuse and ask me the question below?

Dev: What the best choice of firebase database for my projects. Which one is better?

Me: It depends on your data relationship and how you use database. And you have to know the nature of your technology you’ll be using.


Firebase Realtime-Database

Pros

  1. ) It’s faster than Cloud-Firestore approximate 200–300 milliseconds.
  2. ) It’s been proved by lots of company that using on production.

Cons

  1. ) There is only 1 server in the world at California, if the server’s down then you app.
  2. ) It recommends Flat Data-Structure. Many times, It’s make data lots of duplication. Cause if your structure has many level of data. It affects on the performance.
  3. ) You can sort data only 1 field.
  4. ) You can query data only 1 time.
  5. ) Really hard to do a pagination.
  6. ) Not Supporting Full-Text-Search. (Firebase recommends Algolia to make this feature)

Firebase Cloud-Firestore

Pros

  1. ) It recommends Documents Data-Structure. You can keep data in many-levels with out effect the performance.
  2. ) Shallow Query Feature will query data without children. So, you will get only data you need.
  3. ) You can sort more than 1 fields and query with many conditions
  4. ) Store data in Multi-region. Your app will be save and if you’re using Firebase far from the us. The response time will be better.
  5. ) Supporting offline with no coding.

Cons

  1. ) It’s slower than Real-time database approximate 200–300 milliseconds. but I think it can be trade-off.
  2. ) It’s still be in Beta state, but some companys are using even if Beta State.
  3. ) Not Supporting Full-Text-Search. (Firebase recommends Algolia to build search feature).

Why we still need Realtime Database?

  1. ) You READ/WRITE lots of data, Firebase Cloud-Firestone’s cost will be so expensive. Realtime database doesn’t care when you READ/WRITE Data such as Drawing picture apps.
  2. ) Your data has no relationship.

Conclusion

I recommend you using Cloud-Firestore. If your app doesn’t have any condition above. and you’ll get more convenience when using with Cloud-Function. It’s so amazing.