0
votes

How do Google Cloud functions handle requests internally?

Can one nodeapp with function logic inside the Google Cloud function work on a few requests at a time? Or each request is directed to dedicated function with separate node context environment and new requests will not get into google cloud function until it'll finish with the initial request?

Will global persists between function calls? If I increment global.a++ will it be incremented with each request served or it'll start from zero with each request? If i put a variable like global.username = 'bobby' will it be the same during function execution? Or next parallel request to the same function instance while it works on the initial request can modify it so the global.username will be from the last request?

1

1 Answers

1
votes

This is documented thoroughly here: https://cloud.google.com/functions/docs/concepts/exec

Briefly:

  • "each function instance handles only one concurrent request at a time"

  • "when one function execution ends, another function invocation may be handled by the same function instance." However, you cannot rely on state persisting between executions.