user3869231
user3869231

Reputation: 342

Firebase cloud functions - what happens with multiple HTTP triggers at once

I have a firebase cloud function that is an endpoint for an external API, and it handles a POST request.

This external API POSTS data to my cloud function endpoint at random intervals (this cloud function gets pinged with a POST request based on when a result is returned from this external API, and there can be multiple at once and its unpredictable)

exports.handleResults = functions.https.onRequest((req, res) => {
  if (req.method === 'POST') {
    // run code here that handles the POST payload
  }
})

What happens when there is more than one POST request that come in at the same time?

Is there a queue? Does it finish the first request before moving on to the next?

Or if another request comes in while the function is running, does it block/ignore the request until the function is done?

Upvotes: 2

Views: 966

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317362

Cloud Functions will automatically scale up the server instances running your functions when it determines that more capacity is needed. Those instances will run your function concurrently. The instances will be scaled down when they are no longer needed. The exact behavior is not documented - it should be considered an implementation detail that may change over time.

To learn more about this, watch my video about Cloud Functions scaling and isolation.

Upvotes: 5

Related Questions