How to reduce firebase realtime database download cost? [closed]

瘦欲@ 提交于 2021-01-29 16:52:34

问题


Will making 2 database in firebase realtime database help to reduce cost and increase daily download limit of 360MB per day?


回答1:


The simplest way to reduce the cost is by reducing the downloads. You can do that by caching the data on local storage as much as possible and continuously sync sensitive data.

While reading different articles, one article caught my eye. I'll summarize my findings and also add the link to the article.

Optimizations Possible:

  1. Optimize serialized data saved in the database, this can be achieved easily with GSON, a library to handle JSON data that allows changing the name of serialized entities with annotations. (There are many other libraries that can do the same) GSON @SerializedName
  2. Implementing a memory cache that is kept only during the life of the App. This cache works as follows:
  • User opens the app and goes somewhere in the app where any kind of favorites is listed, let’s say Bus Stop favorites.
  • The App requests to the memory cache a list of Bus Stop favorites but as the App has just been launched it returns null.
  • Then the App requests to Firebase only the node containing Bus Stop Favorites, which are downloaded from the internet and then billed once.
  • A copy of this favorites is saved in the memory cache.
  • User plays with favorites, adding, removing or editing them.
  • Every time a modification is done the resulting favorites list is saved in the memory cache and also sent to Firebase (because uploading data is free).
  • Now the user can leave the App, and unless it is explicitly removed from the recent App stack by the user or killed by Android, the user can come back to the App and continue playing around with the Bus Stop favorites without incurring in extra billing.

Link to the article mentioned. Hope this helps!!!.




回答2:


  • try to derive data from other data (for example if you have a voting app, instead of storing the number of people that voted, the number of people that upvoted and the number of people that downvoted, you can store only the upvotes and downvotes and do maths to calculate the total amount of people who voted)


来源:https://stackoverflow.com/questions/62726756/how-to-reduce-firebase-realtime-database-download-cost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!