About Firebase Cloud Function architecture

107 views
Skip to first unread message

Châu Giang

unread,
Jun 15, 2017, 10:32:07 AM6/15/17
to Firebase Google Group
Hi,

I am using Firebase for my project and have a lot of problems in server-side architecture.

My code like that:
var manager = new MyManager(db);
console.log('initialize'); // this initialize log

exports.something1 = functions.database.ref(path1')
    .onWrite(event => {
     return manager.doSome1(event);
    });



exports.something2 = functions.database.ref('path2')
    .onWrite(event => {
return manager.doSome2(event);
    });

And I noticed that:
"initialize" logged twice when deploying. So each function run in each container, so manager that something1 called is different from manager something2 called.
Sometimes when running, 
"initialize" was logged. It means that one function has more container for firebase scaling.
Are the above things true?




Michael Bleigh

unread,
Jun 15, 2017, 11:32:26 AM6/15/17
to Firebase Google Group

Two different functions will *never* share infrastructure, but a single function may reuse an existing instance for multiple invocations to avoid cold start time. You cannot make any assumptions about when reuse happens -- it is automated and based on a large number of factors.


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/df56e904-53b3-41ab-8638-f86ac265d8e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages