admin管理员组

文章数量:1181432

For firebase triggered functions (for instance @on_document_created), how do I specify the memory assigned to single functions?

The firebase.json file does not change a thing, all functions are at 256 mb.

{
  "functions": [
    {
      ...
      "memory": "1GB",
      "timeoutSeconds": 300,
      ...

What changes the memory of the single functions is changing it inside the cloud console, which is laborious.

Is there any way defining it inside the trigger for instance so that I do not have to redeploy it for memory adjustment after I changed the code?

For firebase triggered functions (for instance @on_document_created), how do I specify the memory assigned to single functions?

The firebase.json file does not change a thing, all functions are at 256 mb.

{
  "functions": [
    {
      ...
      "memory": "1GB",
      "timeoutSeconds": 300,
      ...

What changes the memory of the single functions is changing it inside the cloud console, which is laborious.

Is there any way defining it inside the trigger for instance so that I do not have to redeploy it for memory adjustment after I changed the code?

Share Improve this question edited 2 days ago Doug Stevenson 317k36 gold badges453 silver badges472 bronze badges Recognized by Google Cloud Collective asked 2 days ago Raul PonzheimerRaul Ponzheimer 156 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

This is covered in the documentation, which suggests that you can provide the required memory in your source code:

In some cases, your functions may have special requirements for a long timeout value or a large allocation of memory. You can set these values either in the Google Cloud console or in the function source code (Firebase only).

To set memory allocation and timeout in functions source code, use the global options for memory and timeout seconds to customize the virtual machine running your functions.

The example provided is for Cloud Storage, but the options are the same for other types of triggers, including Firestore.

@firestore_fn.on_document_created(
    "my-collection/{docId}",
    memory=options.MemoryOption.GB_1
)

You can see all the options in the API documentation for firebase_functions.firestore_fn. on_document_created accepts FirestoreOptions which includes MemoryOption values.

This did the trick:

@on_document_created(document="collection/{documentId}", memory=512)

本文标签: pythonDefining memory for single firebase functionsStack Overflow