We have the answers to your questions! - Don't miss our next open house about the data universe!

GCP Cloud Functions : Discover Google’s calculation service

- Reading Time: 4 minutes
GCP Cloud Functions : Discover Google's calculation service

To design a new software application, developers often have to provide the entire underlying infrastructure (including servers, storage and other cloud resources). This is no longer the case with GCP Cloud Functions. This Google Cloud Platform service simplifies the work of DevOps thanks to micro-services. Find out more about how Cloud Functions works and its benefits.

What is GCP Cloud Functions?

Cloud functions is a FaaS (Functions as a Service) product that lets you run code in the cloud. Without any servers or containers to manage. GCP Cloud Functions creates single-use functions (or microservices). These then execute specific tasks in response to certain pre-defined events.

The aim is to help DevOps focus on writing code before entering the production phase. In this way, they can write the code while GCP Cloud Functions takes care of managing the entire infrastructure. They don’t need to provision the cloud infrastructure (servers, memory and other resources), just implement the programming functions. As soon as they are activated, GCP Functions connects the various cloud services, limiting orchestration problems.

With this tool, developers save precious time in writing and executing code.


💡Related articles:

GCP Cloud Run: What is it? What’s it for?
Choosing the Right Cloud Provider: AWS vs. Azure vs. GCP Unveiled
GCP Firewall Policy: Everything you need to know about Google’s cloud firewalls
GCP Dataflow: What is it? What’s it for?
Terraform: Using GCP to deploy your infrastructure

Good to know: GCP Cloud Functions is an alternative to Lambdas from Amazon Web Service (AWS).

How does Cloud Functions work?

Create a Cloud function

To connect the various cloud services together, you need to create simple, single-application functions on GCP Cloud Functions. These are associated with events emitted by your infrastructure. As soon as the event occurs (or an HTTP request is made), the function is deployed.

To create a function in Google Cloud, you need to

  • Open Cloud Functions and select the appropriate project;
  • Select the environment (1st or 2nd generation);
  • Name the function ;
  • Authenticate (this involves authorising or not authorising unauthenticated requests);
  • Define the source code and execution environment (depending on the tools used in your technology stack).

Deploy a function

You need to define the parameters for calling the function from your infrastructure. These include the name of the function, the region in which to deploy it, the execution environment, the location of the source code, the entry point in the source code and, above all, the triggers. There are two types of trigger:

  • HTTP functions: this involves calling the function via an HTTP request
  • Events: these fall into 3 categories:
  • Pub/Sub: when a message is published in the Pub/Sub topic.
  • Bucket: when an object is created in the Cloud Storage bucket.
  • Event: when a specific event occurs.

Additional options can be added to these triggers, particularly for networking, security and configuration.

Good to know: to deploy a function on Google Cloud, it is essential to have the necessary authorisations. In many cases, this involves the IAM “cloud function developer” role.

Testing a function

Before deploying a function, it can be tested. That’s why Google Cloud Platform includes an open source emulator. Here you can monitor the effectiveness of Cloud functions, particularly in the event of a bug. The idea is to quickly debug a microservice, without impacting the rest of the application.

And to improve performance, don’t hesitate to create sub-functions. Using small code extracts, you can run unit tests to progressively test the application.

Why use Google Cloud functions?

A service that evolves with use

Scaling is directly integrated into GCP Cloud Functions. So, depending on your code’s needs (workload, memory, etc.), its capacities can be increased or decreased automatically. The idea is to always adapt to usage to maximise the efficiency of your application.

Attractive billing

GCP Cloud Functions offers you a billing system tailored to your usage. You only pay for the time your function is running (calculated to the nearest 100 milliseconds). The default execution time for a function is 1 minute (up to a maximum of 9 minutes).

This billing method is very useful if you only call your functions 2 or 3 times a day. But when hundreds, or even thousands, of users call the functions every day, the bill can quickly escalate. That’s why Cloud Functions is preferred for applications with irregular traffic.

Managing multiple requests

Each instance can be configured to handle a multitude of concurrent requests. To do this, GCP Cloud Functions always provides you with at least one instance ready to handle the different requests.

Google Cloud Functions also supports more complex deployment models, such as the Canary method. In this way, you can easily divide traffic between different versions of the code.


Cloud Functions is an open source FaaS. It is therefore compatible with a large number of programming languages or execution programs (Node.js, Javascript, Python, etc.). The code can then be executed in different types of environment: on site, locally, Cloud run or serverless based on Knative.

And don’t forget that Cloud Functions is part of GCP. It integrates seamlessly with all the other Google Platform services. So you can interact with other services by running the code in a VPC (virtual private cloud). And all in complete security.

Join DataScientest and master GCP Cloud Functions

While GCP Cloud Functions is a highly effective solution for focusing on writing and executing code, DevOps practitioners actually need a multitude of tools to design and deploy applications or software.

And for each of them, training combining theory and practice is absolutely essential. This is where DataScientest comes in. With our DevOps training, you’ll finally master all the software that’s essential to the CI/CD process.

You are not available?

Leave us your e-mail, so that we can send you your new articles when they are published!
icon newsletter


Get monthly insider insights from experts directly in your mailbox