3

It is well known that read/write cost of firebase rtdb is free. With little bit more digging, i could've find out that read/write can actually cost in non-direct ways. Ok, so i've been searching through docs and SO questions to figure out of "what is the exact difference between FIRESTORE READING COST($0.06 per 100,000 documents) and REALTIME DATABASE DOWNLOAD($1/GB) COST", but sadly i couldn't have managed to complete it.

Stored data cost for RTDB($5/GB) is really clear, and i understand that the price billed monthly(this one would be true, right?). But what is exactly a DOWNLOAD cost? Through a few SO questions and official docs, i could've figure out that rtdb download cost is really similar to firestore reading cost, and it is important to specify db.ref path clearly by diving into the final path. But, if the download cost is all about these operations, such as reading json data in a specific field or path, what is difference between concept of firestore reading and concept of these rtdb download operations?

If all these things are already happening in the Earth, the cost of RTDB when it comes to 'conceptual reading' is never free, even if we speak in direct manner. Then why some community members and articles always say "read/write cost for RTDB is free"? I was considering migration of some features from firestore to RTDB since it is well-known that rtdb is free for read and write. The feature is updating a single path(document for firestore) of 500B size hundreds time every month. But this issue makes me really confusing.

Let's say that 100,000 read for firestore is $0.04 and download for RTDB(which seems like reading) is $1/GB. In my calculation, 2,500,000 document reads from firestore is equal to a single GB download from RTDB. It means that if a single operation reads bunch of data larger than 400B(approx.), firestore read-cost is even cheaper than RTDB read-cost. Then there is no reason for me to use RTDB for reading data if single operation needs to retrieve data larger than 400B per operation. It feels like i've got caught by wrong concepts, but it is not easy to get out of this swamp.. ]:

So i hope to make clear of RTDB read/write cost(if it is really free of charge by itself), and the reason why it is better to use RTDB than firestore, when the app have to do lots of read operations(for me, ex. approx. 1,000 operations retrieving 400B-size data per month per a single user). I understand that a few firebase gurus are thankfully contributing SO's firebase tag. I've tried to write the question as clear as possible, but think there would be some unclear parts in the question. So, comments will be really appreciated! Hope this question would reach to you.. Thanks in advance [:

2 Answers 2

7

I have created a very handy spreadsheet calculator that calculates the rough size of the payload and scales per user while also factoring in the free tier usage as well. You can enter your values at the top and get a decent result.

But to summarize, Realtime DB is highly expensive to read per KB while Firestore is rated for up to 1mb (potential) per read while writing to Realtime is extremely cheap, I have confirmed that besides overhead, it is free to write to realtime db.

Realtime db is not as economical compared to Firestore and is designed to cover some caveats of Firestore. Realtime Billing for reads (download) is the (data + overhead) rounded up to nearest kb

TLDR:

  • Firestore is ideal for high reads, low writes, static information.
  • Realtime is better suited with low reads, high writes, volatile information.
2
  • 3
    Awesome answer @DIGIByte. Also love the calculator. 👍 Jul 30, 2021 at 15:00
  • both answers are wonderful!! Thank all of you for awesome-practical one and cool conceptual one [:
    – tsitixe
    Aug 3, 2021 at 7:46
2

When reading documents from Firestore you pay for:

  1. Document reads - The cost to read the document on the server.
  2. Network egress - The cost to download the data to the client.

In most scenarios we see the cost for developers using Firestore coming more from document reads, as the cost per GB is comparatively low.


When reading data from the Realtime Database, you only pay for:

  1. GB downloaded - The cost to download the data to the client.

Here the cost mostly comes from the size of the data you download. It's quite similar to the Network egress from Firestore, but at a higher cost per byte read (and of course you then don't pay for the read operation on the server itself).


While a calculator (such as the one from DIGI Byte, or the one on the pricing page) is going to be best, the rough guidance is that if you perform many small reads and writes, RTDB is going to a better choice, while if you perform fewer writes and/or more larger reads, then Firestore is often the better choice.

4
  • To make things a bit clearer, is it true if i say below list? [: 1. if granted client user send read-request to firestore, the app should pay for both reads and network egress(same for writes, deletes) 2. in case of rtdb, it would be better to extend rtdb with cloud functions to deal with huge rtdb data on serverside, then transfer small amount of key data back to client(it seems like data download with cloud functions is far cheaper than that of rtdb: $0.12/GB vs $1/GB) since Outbound networking from cloud functions is conceptually equal to rtdb's data download!
    – tsitixe
    Jul 31, 2021 at 6:37
  • hope this comment also reach to you..!!
    – tsitixe
    Jul 31, 2021 at 6:39
  • 1
    1) When you read a document from the Firestore server to the client, you pay for both the document read operation and the egress bandwidth. There is no egress bandwidth on writes, and no document read charge on writes and deletes. 2) There is no blanket recommendation here, but the calculators mentioned should give you a good place to start on the price part of the comparison. Jul 31, 2021 at 14:25
  • Thank you!! I've actually waited for your answer.. Learning from master [:
    – tsitixe
    Aug 3, 2021 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.