7

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?

AL.
  • 36,815
  • 10
  • 142
  • 281
Arun Chaudhary
  • 277
  • 3
  • 13
  • I could not find at firebase document. But I have seen another question on this platform asks 'why only 3 topics'. – Cappittall Jan 18 '18 at 15:19
  • @HakanC That sounds more like the number of topics you can use in a single subscription. It was also recently increased from 3 to 5. :-) – Frank van Puffelen Jan 18 '18 at 15:30
  • @FrankvanPuffelen I couldn't find any document stating that in one call one registration token can be subscribed to multiple topic. Could you point to that documentation where it is mentioned about subscribing to 5 topics at a time? – Arun Chaudhary Jan 18 '18 at 16:44
  • Never mind, I got it the wrong way around: you can **send** messages to multiple topics at once, by writing expressions as shown here: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging#build_send_requests. That also contains the limit I was thinking of "You can include up to five topics in your conditional expression..." – Frank van Puffelen Jan 18 '18 at 17:32
  • AFAIK, limitations regarding topics were all removed (topic creation and subscriptions) after moving from C2DM to GCM (see [here](https://stackoverflow.com/a/15017586/4625829)) -- looking at this [old blogpost](https://developers.googleblog.com/2015/12/google-cloud-messaging-weve-come-long.html?utm_source=Android+Weekly&utm_campaign=1cb848077c-Android_Weekly_184&utm_medium=email&utm_term=0_4eb677ad19-1cb848077c-337844217) again, it does only say that creating topics are unlimited, so are the number of subscribers, but not the subscription for token. Will take a look around again. – AL. Jan 18 '18 at 17:46
  • 1
    @AL. Thanks for formatting my question. – Arun Chaudhary Jan 19 '18 at 05:33

2 Answers2

14

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.

Arun Chaudhary
  • 277
  • 3
  • 13
8

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.

maswerdna
  • 315
  • 2
  • 10