Skip to content

Instantly share code, notes, and snippets.

@rominirani
Last active March 10, 2021 15:14
Show Gist options
  • Save rominirani/1d7f6d225862100871c9f98c760daeca to your computer and use it in GitHub Desktop.
Save rominirani/1d7f6d225862100871c9f98c760daeca to your computer and use it in GitHub Desktop.
Timeout property in Google Cloud Functions

Timeout property in Google Cloud Functions

When you configure Google Cloud Functions, you can set the Timeout property of the function. This property specifies the amount of time that the function will keep running if you do not complete the function. The default timeout is set to 60 seconds.

While this might look ok, keep in mind that when it comes to Cloud Functions pricing, one key factor you are charged for is the amount of time that the functions are running. So you want to keep this to a minimum and not let it timeout.

As a best practice, you should use the appropriate mechanism to complete the function as soon as possible and this depends on Function type.

  • HTTP Functions: Invoke the the send(), resend() or the end() methods on the Express JS response once you are done with the functionality.
  • Cloud Storage and Pub/Sub Functions: Invoke the callback() function once you are done.

This will prevent the function from being kept running till the timeout occurs, thereby saving you money since you are charged for the time that the function executes.

@pdfabbro
Copy link

I set my cloud function to 540 seconds but it keeps timing out after 60 seconds anyway. I've added more memory to it too. Not sure what else to try/why the time out setting is not being taken into account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment