With a user base of 200,000 and a live session underway, the need to send push notifications to all users simultaneously arises to inform them of the live session in PHP. However, Firebase push notifications can only be sent to 1000 users at a time. This results in the last user receiving the notification 10 minutes after the session has gone live.
In light of this issue, what steps can be taken to address this limitation and ensure all users receive the notification promptly?
2
Answers
Even under the new limited quota regime of FCM, it allows each project to send 600K messages per minute. For more on this, see the documentation on sending messages at scale.
So if you reach a peak throughput below that, it is not FCM that is limiting, but your own infrastructure that calls FCM. Consider making multiple parallel calls to the FCM backend to improve throughput, and to use HTTP2 multiplexing to amortize the connection overhead per call.
The unofficial Firebase Admin SDK for PHP (Disclaimer: I’m the maintainer) allows you to send individual FCM messages with a throughput of ~500 messages per second (this benchmark was done on a local computer with mediocre internet connection) by calling the FCM API Endpoint with HTTP/2 asynchronously.
You could chunk the messages and push commands to an, again asynchronous, queue with multiple consumers to handle a large set of messages in a shorter amount of time.
This assumes that you currently do send one message at a time to individual users. Unless each message is different/personalized (which I doubt), this is highly inefficient, though.
The far better solution would be to subscribe the target devices to an FCM topic (e.g. retroactively with an Admin SDK, or from each device (iOS, Android, Web), send a single message to the topic and let Firebase handle an efficient delivery.