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.
This means that Cloud Firestore will try to retrieve an up-to-date (server-retrieved) snapshot, but fall back to returning cached data if the server can't be reached. This is how we can reduce the number of reads in Cloud Firestore, by forcing the SDK to use only the offline cache and get the data only upon request.
The limit you're referring to is the limit for the number of concurrently connected users to Firebase Realtime Database on the free Spark plan. Once you upgrade to a payment plan, your project will allow 200,000 simultaneously connected users.
256 MB from the REST API; 16 MB from the SDKs. The total data in each write operation should be less than 256 MB.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With