December 23, 2021

Serverless computing with the example of Google Cloud

AuthorLuka Penezić

Agility is playing an increasingly important role, and not only in IT. A modern and flexible IT infrastructure is indispensable here. In the area of the cloud, there is serverless computing, for example, for fast and efficient work. Serverless computing is a type of cloud service in which users create and run applications - without having to give a thought to the underlying server(s).  

In the article "What is Serverless Computing?" we have already described the term serverless computing and all its possibilities as well as advantages and disadvantages. The article that follows now highlights how serverless computing works in the environment of the Google Cloud provider.

Serverless Functions in Google Cloud

Google Cloud, as all other cloud providers, offers scalable pay-as-you-go functions as a service (FaaS) called Cloud Functions. Cloud Functions has a simple and intuitive developer experience. Just write your code and let Google Cloud handle the operational infrastructure. Develop faster by writing and running small code snippets that respond to events. Connect to Google Cloud or third-party cloud services via triggers to streamline challenging orchestration problems. Google Cloud Functions supports various programming languages, including Python, Node.JS, GO, Ruby, Java, .NET and PHP. (Source)

Step-by-step guide: How to get started in Google Cloud?

At the beginning the programming language which will be used should be defined. The deployment will be executed by using the gcloud command-line tool. Then it’s easier to start gradually by following  these steps: (Source)

Step 1: Create new account (300$ free credits to run, test and deploy workloads)
Step 2: In the Google Cloud console, on the project selector page, select or create a Google Cloud project
Step 3: Make sure that billing is enabled for your Cloud project
Step 4: Enable the Cloud Functions and Cloud Build APIs
Step 5: Install and initialize the Cloud SDK
Step 6: Update gcloud components
Step 7: Prepare your development environment

After the preparation it gets really down to business. To simplify work, you can clone the sample repository to the local machine (different for every development environment). Then switch to the sample directory and edit the sample code. To deploy the function with an HTTP trigger, run the following command in the directory containing your function (example):  

When the function finishes deploying, take note of the httpsTrigger's url property and visit the URL in the browser. TheHello World! Message should be visible. To delete the function, run the following command (example):  

Utilization of Google Cloud Functions

Cloud Function is intended for smaller units of code that are triggered by cloud events or HTTP requests and are only billed per request, which can result in savings for applications with low or uneven traffic patterns. A function with an event trigger does not have a public URL. It executes in response to an event within your Cloud project. For example, a function might execute in response to changes to data in a database. (Source)

Cloud Functions run in a fully managed, serverless environment where Google handles infrastructure, operating systems, and runtime environments completely on your behalf. Each Cloud Function runs in its own isolated secure execution context, scales automatically, and has a lifecycle independent from other functions. (Source)

What are benefits of Google Cloud Function?

Comparing to the other top cloud providers, GCP Cloud Functions has a few less bells and whistles but is still fairly comparable to the other two. One of the greater benefits with GCP is the so called “cold start”. When a new instance handles its first request, the response time increases, which is called a cold start. Looking on the same package size, AWS and GCP are side by side, but MS Azure  struggles a little bit. (Source)

Limitations of Google Cloud Functions

The feature set is very limited compared to a competing service like AWS Lambda. Unless Google invests more resources and gives importance to Google Functions like other container-based services, AWS Lambda will have more significance for developers . If you are a Google Cloud user or want a spectrum of services to deploy microservices and cloud functions, Google Functions along with Google Run, Google Kubernetes Engine, and Google App Engine may be a good choice.(Source)

In our blog series on the topic of "Serverless", we took a closer look at the largest providers for serverless computing such as IBM Cloud Functions, Google Cloud and AWS Lambda.  

At Libelle IT Group, we also rely on the advantages of the cloud and provide you with various solutions. Use the cloud editions of Libelle DataMasking (AWS / Microsoft Azure), Libelle SystemCopy (AWS / Microsoft Azure) or Libelle CloudShadow (IBM Cloud) now.

Recommended articles
December 22, 2022 Libelle IT Glossary Part 22: What is DevOps?
November 30, 2022 The 12 Factor App Part 3: (Disposability, Dev/prod parity, Logs, Admin processes)

All blog articles