Reputation: 185
I am working on a firebase project. I have a cloud function that triggers on a change of a value of one of my collection in my RealTimeDB.
If a Bulk of changes are applied in the same time, how does it invoke my cloud function? Will it invoke the cloud function at the same time , or will it call my cloud function in a sequential order, like one by one.
I am just worried because ,this cloud function has to fetch a value from another collection, which will vary from time to time. And if the order of execution changes, They may fetch a wrong value at that time.
Upvotes: 3
Views: 2521
Reputation: 753
Limitations and guarantees on Firestore applies for Firebase too [1].
"Ordering is not guaranteed. Rapid changes can trigger function invocations in an unexpected order."
In cases where inbound request volume exceeds the number of existing instances, Cloud Functions may start multiple new instances to handle requests. This automatic scaling behavior allows Cloud Functions to handle many requests in parallel, each using a different instance of your function [2].
Upvotes: 0
Reputation: 317968
Cloud Functions does not guarantee any ordering of events. Events could be processed in parallel, as there could be multiple server instances handling them simultaneously. You will need to take this into account if events could be generated rapidly under load.
Upvotes: 6