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);
Related
I am looking for max allowed active connections to Firebase Realtime DB in Blaze Plan for below
How many active RtDB listeners (StreamSubscription) from single device
How many active RtDB listeners (StreamSubscription) to single db from all connected devices
In below link I see,
total Simultaneous connections allowed are 200,000
https://firebase.google.com/docs/database/usage/limits
(A simultaneous connection is equivalent to one mobile device, browser tab, or server app connected to the database.)
But I could not find StreamSubscription limit per device, and StreamSubscription limit per db.
More a design question / explore options - I have a Firebase Realtime Database backed project where I have IOT-like devices (ESP32) that periodically measure environmental conditions and stores data in the database, and a flutter app that users use to associate devices with their account, view data and update device settings.
My question is about the best setup for the IOT devices - i currently have them all using a single service account to access the database and insert new readings. I'm concerned this may open up the project to security issues, and that there is no way to restrict security priveledges of a single device.
The other option is to create individual user accounts for every device (each device would have to register themselves with their own unique id). This would then allow every device to be disabled individually and operate through the security rules defined for the database, but lead to a larger number of users in the auth db and more complex iot device code.
Am I missing anything from the above? Has anyone done something similar and can offer some design insight?
i currently have them all using a single service account to access the database and insert new readings.
You should only use a service account in trusted environments, as they have full unrestricted access to your Firebase project. In all other scenarios, consider regular SDKs such as the non-privileged Node.js SDK that is great for using on IoT devices.
I'd like to use Ionic 4 + Firestore to provide app with offline and live sync capability.
Target deploy to Native App (iOS, Android), electron App (Windows and Mac), PWA.
Is firestore local cache persistent in hybrid app?
What type of storage firestore cache using?
Will it be something like localstorage, which will be delete by android / iOS from time to time / while low storage.
I'm testing with below code and did enablePersistence, offline mode is working just fine.
But it seem that the the it count all documents read per app launch.
Example, I'm having 100 documents.
a. While app first launch, it should count as 100 read as it sync all data to local cache.
b. While 2nd time I launch the app, assume, no document was updated, it shouldn't count any read right?
c. Because from my monitoring, the read count increase every time I launch the app.
d. Will it be any possible like, no document was updated, but my code force to fetch data from server then it consume the read count?
Thanks.
getChatMessages(groupId) {
return this.db.collection(`groups/${groupId}/messages`, ref => ref.orderBy('createdAt')).snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
}))
);
}
I guess you are talking about the offline data, I think your question can be answered with the docs.
1.1. Is firestore local cache persistent in hybrid app?
It should since the functionality comes with the client libraries that you should be using into your hybrid app.
From this doc:This feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline. YES, it’s local storage.
1.2. What type of storage firestore cache using?
From this doc: Cloud Firestore is a cloud-hosted NoSQL database. You store data in documents, which contain fields mapping to values.
2. a - You stated: “While app first launch, it should count as 100 read as it sync all data to local cache”, but as mentioned above, Firestore will only load the data that your app is using actively, so mostly your are seeing a subset of your total data (100 documents).
b- Regarding your claim about assuming no document modification, anyway your app will sync the data, which already means a validating request. At this doc it’s stated:
The Cloud Firestore client library automatically manages online and offline data access and synchronizes local data when the device is back online.
c- This claim is correct and points to the sentence I pointed before.
My app run in background. If app run in background, is still simultaneous connected with realtimeDB? Or if this app doesn't use realtimeDB for a while, does not count simultaneous connected?
If it's count anyway, can I only get 100,000 user?
Your app is connected to the realtimeDB as long as your listener is active. If you want to stop listening you need to remove the listener according to your needs and to the activity cycle.
For Android you can use this code in your onDestroy() method.
databaseReference.removeEventListener(valueEventListener);
Hope it helps.
I am answering your three part question in order..,
Firebase database library manages the connection to your database in the backend and this starts right away at the start of the app and this starts counting against your simultaneous connections and when this limit reaches the Max Connections limit of 100k any new connections will be dropped until the existing connections drop by either closing the app or app goes offline after a specified time-out or forcefully closing the DB connections by calling
FirebaseDatabase.getInstance().goOffline()
You can however know the whether a given client is connected or not by using the listener at FirebaseDatabase.getInstance().getReference(".info/connected") this however works locally and doesn't explicitly connect to FirebaseDatabase cloud instance., more can be read here
Once you implement the above connection listener you will see that the SDK manages this dynamically in a way that the connections disconnect automatically if there are no listeners attached and if no DB operations like .setValue() are made in the app in last 60 seconds.., but the presence of ValueEventListners will override this and will ensure continuous connectivity with the DB. again this can be overridden and the connection can be severed by explicitly calling FirebaseDatabase.getInstance().goOffline()
Coming to the Max Limit of 100k simultaneous users; as can be seen in Firebase Plans
There is a limit of 100,000 simultaneous connections per database on
the Flame and Blaze plans. See Pricing FAQ for more information.
If you cross this and for scaling you need to increase the limit, you can explicitly ask Google Firebase Team for the support and they will handle this on a case by case basis to ensure your app can scale as required when required..
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.
I use Firebase's Spark (free) plan.
Are the limitations that are given to (database simultaneous connections, database storage, etc.) are project based or user based.
For example I have two projects:
The first project have (an android app and an iOS app) and have 80 database simultaneous connections.
The second project has only an android app with 50 database simultaneous connections.
Am I in this case exceeding the limitation (user based) or not (project based)?
All limits and pricing indicated on the Firebase pricing page apply to each separate project.
So in your example neither project would be exceeding the limits of its free plan.