How many topics an app instance can subscribe in FCM? - firebase

As mentioned in FCM documents, unlimited topic can be created for one Firebase application. But as the Firebase Admin SDK document: explains an error:
messaging/too-many-topics:- A registration token has been subscribed to the maximum number of topics and cannot be subscribed to any more.
I was not able to find this threshold value of maximum number of topics. Can anybody explain, what is the limit? How many topics an app instance can subscribe to in FCM?

I found the answer by running a subscription script for an app instance. After subscribing to 1999 topics, for the next subscription it started giving error: messaging/too-many-topics.
So the threshold value is 1999.

As much as the selected answer is correct, I'll like to post an absolute answer here.
Google Firebase Cloud Messaging
Some things to keep in mind about topics:
Topic messaging supports unlimited subscriptions for each topic.
However, FCM enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.

Related

Can Firebase Messaging topic works well with 100K subscriptions?

I am a newbie to FCM.
I have a plan to create an FCM topic that contains 100.000 subscriptions.
Then I send a notification to the topic.
My question is: will 100.000 notifications be sent out successfully?
My question is: will 100000 notifications be sent out successfully?
Yes, it will. According to the official documentation:
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
So first of is free of charge.
And according to the official documentation regarding topic messaging, it is said that:
Topic messaging supports unlimited subscriptions for each topic. However, FCM enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.

Flutter FCM Topic named like a document

I am new to firebase cloud messaging and i search the best way to send notifications to clients.
I want people to be able to subscribe to new entry in subcollection like this :
books/{bookID}/comments/{commentId}/reply/{replyId}}
Is that bad if i use that kind of syntax?
so i can push notification on that topic when new reply are created
void fcmSubscribe(String bookId,String commentId) {
firebaseMessaging.subscribeToTopic('book-${bookiD}_comment-${commentId}');
}
or i need to use Individual Device Notifications and create entries like this
books/{bookID}/comments/{commentId}/notifications/{tokenId}}
i want to avoid firestore Read and Write.
You can use whatever valid topic names that you want. Use whatever you like - it's your choice. There is nothing particularly "bad" about your choice of name, as long as it works for you. Things can only go badly for you if you exceed one of the documented limits for topic messaging:
Topic messaging supports unlimited subscriptions for each topic. However,
FCM enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM
servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded")
response. Retry with exponential backoff.
If you're thinking that FCM is tied in any way to Firestore, that's not the case. You are not obliged to make anything match between your Firesore documents and your FCM topics.

Firebase console TPS handling of push notification

I have 1 million user base, so if I'm sending push notification through firebase console my active users get increases drastically which causing some trouble at server end for few time. So I have two questions regarding that -
What is the transaction limit(TPS) of firebase for sending notification.
Can I tune transaction limit(TPS) of firebase console according to my requirement?
There isn't any limit to sending notifications with FCM. Although if you are using topics, and you're sending too many messages at a time to a single topic, you might receive the Topics Message Rate Exceeded error from time to time, in which case you could just implement an exponential backoff.
So to answer your questions:
There isn't any.
I'm not sure what you mean by this. The console contains the data about your Firebase project and some features related to interacting with your app (like the Notifications Console), that's about what it could do.

Limitations for Firebase Notification Topics

I want to use Firebase notification for my android application and what i want to know is that is there any limitation for number of topics ? or for the number of users that can subscribe a topic ?
For example can i have 10000 topics with 1 million users for each of them ?
There is no limitation on the number of topics or subscriptions. There was a limitation of 1 million subscriptions for the first year after topics was initially launched but that restriction was removed at this year's (2016) Google I/O. FCM now supports unlimited topics and subscribers per app. See the docs for confirmation.
Topic messaging supports unlimited subscriptions for each topic. However, FCM enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.
Check this
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

Maximum number of topics a device can subscribe to in FCM

Documentation for topic messages for FCM says the following two points
Just wanted to know what is this excessive number of topics? Any approximate value to it? Also, the documentation doesn't say anything about creation of topics. How to create/delete a topic?
Another question -
Document says it takes time to show the topic on firebase console, so, we can't send notifications unless the topic is visible on firebase console (even programmatically)?
Thanks in advance
For future questions, please limit yourself to a single question per post. But here are the answers that I know (or a fairly educated guess):
The limit on the number of topics a client can subscribe to is to counter abuse. It is not a documented value.
A topic is auto-created when a client subscribes to it.
There is no API to delete a topic. It will automatically disappears when nobody is subscribed to it anymore.
You can only send notifications from the console once the topic shows up. You can send notifications from your app server using the Firebase Cloud Messaging API at any moment.

Resources