Reputation: 2639
I am using Firebase's cloud functions to execute triggers when a client adds something to the database, but it seems like these triggers take long time to execute.
For example, I have a trigger that adds a creation date to a post whenever a post is added to the database, and it takes like 10 seconds to complete. Also, I have larger triggers that take even longer.
Is there like a "best practice" I am missing? Am I doing anything wrong?
Upvotes: 5
Views: 1958
Reputation: 2639
I've found that the reason that Cloud Functions sometimes takes time to respond, is because they have a "warm up" period, meaning that the first time you call a cloud function it begins to warm up, and it won't be fully responsive until it is warm.
After it warms up, it will be as responsive as you would expect.
The reason for this behavior is resource resource balancing - If you don't use a function for some time, it will shut down and clear resources so other functions will be more responsive.
Upvotes: 5