In Firebase Realtime Database I want to set limit for number of data read request per user or per IP.
Similar like Firebase Authentication Limits(e.g New account creation 100 accounts/IP address/hour)
Is there any way to achieve this in Firebase Realtime Database ?
The only way to implement this would be to force client apps through a backend API that you control. That API will have to record the amount of data read per IP, and reject requests that exceed your limits.
Otherwise, there is no way to impose limits as you describe. It's not a matter of simple configuration.
Related
So I have been coding a realtime chat app with flutter and firebase. Apparently there is a simultaneous concurrent connection limit of 200k on the RTDB, if my app reaches these limits, firebase suggests that I shard my database.
The problem with that is, that I cannot completely separate data from one database instance to another, as it's a realtime social media app, and one user should be able to access other user's information such as name, bio etc.
What I want to know is that, should I stick with firebase for this, or should I go with some other database.
You can always access data from multiple shards on your app as long as you know which shard does the required data belong to. You can also use Firestore along with Realtime database to suit your needs. Checkout the following answer for an example:
How to shard data Realtime Database for chat app?
This stores all user profiles and basic information about the chats (including which shard is the conversation stored in) which makes it easier to query list of chats of a particular user(s) from Firestore and then read messages from realtime DB.
How can I limit number of reads/writes from one IP in firestore?
P.S. I don't have any authentication in my app
Limiting any sort of access by IP address is not possible with Cloud Firestore. Instead, you should consider actually using some authentication, force requests through a backend you control, and perform per-user auditing from there.
The firebase auth doc shows that you can only make Firebase Auth API calls up to 500 requests/second per service account & 1000 requests/second per project.
e.g. If I use Firebase Auth Admin SDK to invoke getUserByEmail or updateUser, do these operations count toward API limits?
How about verifying id tokens using verifyIdToken API? If my project verifies all requests coming in to the server from clients by verifying authIdToken, does that mean that my server's upper scaling threshold will be 1000 requests/second per project because the server's one of downstream services, Firebase Auth, can only accept up to 1000 requests/second to verify auth id tokens?
Firebase doc seems to be lacking details related to these API limits.
Yes, 1k/s includes all limits from the Admin API. I feel if the downstream can only handle 1k/s you can always implement a backoff or throttle algorithm to handle higher burst load at times. I assume these are mostly sufficient for user auth as user don't login frequently. For machine to machine, I suggest you use a different auth system.
I'm currently using Firebase for an online Android game in Kotlin (school project) to authenticate/register users. We're going to release our first version for testing, and I would like to set a limit of people that are able to sign up with Firebase (20 to be specific). Is this possible? Thank you in advance.
There is no way to limit the number of people that can sign in to Firebase Authentication. All authentication does is allowing you to say (and prove) that "I am Max", and there is no way to restrict in Firebase Authentication who can do that (beyond creating your own custom identity provider).
But you can limit what these users can do in the rest of your app. If you're for example using the Firebase Realtime Database or Cloud Firestore, you'd restrict the users who can access the database with their respective server-side security rules (Realtime Database, Cloud Firestore).
If you have your own backend servers, you'll want to pass the ID token from the user to that server, and verify the token there to allow who can access what resources.
On Firebase pricing page it has been stated that:
What is a "simultaneous database connection"?
A simultaneous connection is equivalent to one mobile device, browser tab, or server app connected to the database. Firebase imposes hard limits on the number of simultaneous connections to your app's database. These limits are in place to protect both Firebase and our users from abuse.
The Spark plan limit is 100 and cannot be raised. The Flame and Blaze plans have a limit of 100,000 simultaneous connections per database. If you need more than 100,000 simultaneous connections, contact Firebase support.
This limit isn't the same as the total number of users of your app, because your users don't all connect at once. We encourage you to monitor your peak simultaneous database connections and upgrade or add more databases if needed.
On the last paragraph, what does it mean by adding more databases? Because as far as I know there is only one database in a project and multiple nodes inside that database. Does it mean creating multiple projects?
Yes, it means having a separate project as you can only have 1 database per project.
Update (2018 - 2019):
As of writing, Firebase now supports multiple Realtime Database instances per project. The database limits are now 100 for Spark, 200K for Flame and 200K per database for Blaze.
There can be multiple FirebaseApp instances. One will be initialised by default from the json file values, and the other you can create yourself, e.g.
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:530266078999:android:481c4ecf3253701e") // Required for Analytics.
.setApiKey("AIzaSyBRxOyIj5dJkKgAVPXRLYFkdZwh2Xxq51k") // Required for Auth.
.setDatabaseUrl("https://project-1765055333176374514.firebaseio.com/") //Required for RTDB.
.build();
FirebaseApp.initializeApp(this /* Context */, options, "secondary"); //
Retrieve my other app.
FirebaseApp app = FirebaseApp.getInstance("secondary");
// Get the database for the other app.
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(app);