Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is memory allocated to a Google Cloud Function?

Today I got this error in cloud function:

Function killed. Error: memory limit exceeded

My function is based on authenticated-json-api example of Firebase sample functions. Because it worked like a charm, I extended it with multiple routes and multiple tasks like connecting with multiple external api, turning base64 strings into pdf on storage, validation, logging, and so on...

I removed some routes and it looks more stable now. My question now is: Can there be a limit to the amount of code / processing there can be within a single function. And would it be a better approach to split them up in multiple express api's ?

I also found some questions about allocating memory to specific functions. However, I can't find the option in Google Cloud Platform to change it nor the option in firebase package.json to set it.

like image 567
p3sn Avatar asked Feb 05 '23 07:02

p3sn


1 Answers

I found the solution:

  1. Go to the Google Cloud Platform Console (not the Firebase console)
  2. Select Cloud Functions in the menu
  3. Now you see your firebase function in here if it's correct. Otherwise check if you selected the right project.
  4. Ignore all checkboxes, buttons and menu items, just click on the name of the function.
  5. Click on edit (top menu) and only change the allocated memory and click save.

Regards, Peter

like image 100
p3sn Avatar answered May 16 '23 05:05

p3sn