Skip to content

Concurrency with Cloud Functions for Firebase V2 #138

@leomp12

Description

@leomp12

Is your feature request related to a problem? Please describe.
Concurrency sometimes is important...
E-Com Plus and integrated solutions webhooks may occur almost at the same time, and it comes with some problems to process status changes and other flows.
Also, we like to be fast and cold starts are not cool 😛

Describe the solution you'd like

Our upcoming version of Cloud Functions uses Cloud Run as its underlying infrastructure. You'll see fewer cold starts because each function instance will now be able to handle 80 concurrent requests by default, as opposed to the current Cloud Functions for Firebase limit of 1.

With Cloud Functions 2nd gen we can enable concurrency, then receive many webhooks at the same execution to be able to control with easy "duplicated" webhooks:

const handlingIds = [];
if (!handlingIds.includes(resourceId)) {
  handlingIds.push(resourceId)
  /* await do stuff */
  const handlingIndex = handlingIds.indexOf(resourceId)
  handlingIds.splice(handlingIndex, -1)
}
// skip handling current webhook if same resource id already being treated

Describe alternatives you've considered
#137

Additional context
Cloud Run seems to be the best of both Worlds, but we can deal with Firebase Alpha (private) features? It is still very important that partners can use this starter template with easy.

Update: public beta

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions