How to limit rate of data reads from Firebase?

天涯浪子 提交于 2020-01-15 04:40:32

问题


I would like to limit the rate of data reads per user from the Realtime Database. There are good ways to limit writes like described here but I can't find any solution on how to limit data reads.

Can this be done with Security Rules, Cloud Functions or can I limit it somewhere in the Firebase account? I have checked the documentation but can't find the answer.


回答1:


This applies to both Realtime Database and Firestore, except with different terminology. (Location == document)

You won't be able to do this without also writing some value at a location in the database every time a read is performed. You can't write a location in a security rule, and you can't force the client to write at the same time as a read.

Even if you were able to write a location in a rule to use in a rate limit, you would then have to read that location for every read that must be limited, and that kind of defeats the purpose of a rate limit (since they could continue to try to read a restricted location in a way that just causes more reads to happen).



来源:https://stackoverflow.com/questions/54508235/how-to-limit-rate-of-data-reads-from-firebase

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