Cloud Functions

Introduction to the cloud functions.

As the world is moving towards a microservices architecture, event-driven programming is becoming more popular. To support the decoupled and event-driven architecture with Google Cloud services, we have Cloud Functions compute service. Let’s see what are cloud functions.

Introduction

Google Cloud Functions is a lightweight, event-based, asynchronous compute solution that allows you to create small, single-purpose functions that respond to cloud events without the need to manage a server or a runtime environment

Cloud Function will charge you for the resources used only during the execution time of the function. Cloud functions are normally used to carry out those tasks which are invoked via an event. And also can trigger other services.

Dashboard

To access the cloud function dashboard, open main menu > Compute > Cloud functions.

Click on the button to create a cloud function. In the form, scroll down to triggers and check out the list of available triggers.

Limitations

Some of the limitations of cloud functions are you can not execute tasks that need:

  • High memory like > 4GB
  • Longer execution time like > 9 minutes.

So, if you are trying to build a Dockerfile that takes more than 9 minutes then the function will probably fail. Keep these limitations in mind whenever you include Cloud Functions in your architecture.

Language support

Cloud function currently supports the following languages only:

  • Python
  • Go
  • Java
  • Node.js

Support for .Net is still in beta mode.

Usecase

The most common use cases of Cloud functions are:

  • Processing file uploads: Whenever a user submits an image using the form then to carry out compression you can use the cloud function. Once the image is compressed then it can be stored in a Cloud Storage bucket.

  • Smaller microservices mobile backends: You can write functions to display data from any source or to display the list of products on mobile devices.

  • On-demand Video analysis: Like image compression, you can use GCP’s ML APIs to analyze the video content uploaded by the user.

There are numerous use cases for cloud functions. Cloud functions are more frequent in almost every decoupled cloud solution.

Lab

Complete the following lab to get hands-on experience of cloud functions.

Get hands-on with 1400+ tech skills courses.