简体   繁体   中英

Google cloud function triggered by firebase realtime database events

Apparently some of onCreate/onDelete events our cloud function is triggered by are received more than once! We've observed them arriving even 3 times a few seconds apart from each other spread between instances of the cloud function. Is it a normal behavior or there is something we've been doing wrong?

Have a look at the content of this "Firebase Google Group" post , that I paste below. It was written in August 2018 but is still fully valid at the time of writing this "copy/paste answer".

Cloud Functions typically guarantees that your functions are run "at least once", meaning that it's very possible (but typically rare) that an event may get delivered to your function more than once. To deal with this, your functions should be "idempotent", meaning that the receipt of the same event multiple times should result in no further changes to whatever it is you need to update. This can be kind of challenging, but it's one of the properties of serverless systems that needs to be dealt with, if it's problematic for your app.

https://cloud.google.com/functions/docs/bestpractices/tips#write_idempotent_functions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM