How to reduce Firestore costs?
A simple solution for reducing the costs in Firestore through database refactoring.
As we already know, Cloud Firestore is a scalable, cloud-hosted, NoSQL, real-time database from Firebase and Google Cloud, and it’s is optimized to store large collections of small documents. When using Firestore, the mechanism for billing is related to the number of reads, writes, and deletes we perform. Since the most frequent operation in an application is the reading, we should always design an efficient database structure, in order to avoid higher bills.
So I’ll try to explain in this article, a solution that can be applied to multiple types of Firebase projects. I will take a concrete example just to make it easier to understand. So, stay with me till the end.
I think that nowadays, all of you are already familiar with Youtube, Facebook, or Reddit. In each one of these projects, the users can interact with each other through comments and replies to comments. So a popular post or a video might get thousands of comments, or why not, even tens or hundreds of thousands of comments and replies. I’ve personally seen a single Youtube video, getting millions of comments.