Jump to Content
Developers & Practitioners

5 things not to do with Cloud Functions, and 5 things you absolutely should do instead

December 1, 2021
https://storage.googleapis.com/gweb-cloudblog-publish/images/gcf.max-2600x2600.png
Sara Ford

Senior Developer Relations Engineer

Martin Skoviera

Technical Solutions Engineer

Over the past several weeks, you've seen a collection of the most common questions and misconceptions the Cloud Functions Support team sees about Cloud Functions. Here is a recap of these most common "anti-patterns" and what you should do instead:


  1. How to write event-driven Cloud Functions properly by coding with idempotency in mind: We explored what idempotent functions are and how this design pattern is important for background-triggered functions.

  2. How to reuse Cloud Function instances for future invocations: We covered what global scope is for a Cloud Function, when to use, and what issues to look out for when used incorrectly.

  3. How to establish outbound connections correctly:  We explained how to make outbound connections correctly by using explicit timeouts on your outbound calls. 

  4. How to handle Promises correctly in your Node.js Cloud Function: We shared how to verify that you are handling promises correctly in Node.js to avoid saving undefined or cached data in your database.

  5. How to run background processes correctly in Python: We cautioned why you should avoid running background tasks in Cloud Functions and explained why we recommend using Cloud Tasks instead.

We hope you've found this series helpful! Please let us know if you have any questions or ideas about best practices using Cloud Functions. You can reach us at @GoogleCloudTech on Twitter.

Posted in