5

Google Cloud Functions Tutorial : Overview of Computing Options

 3 years ago
source link: https://rominirani.com/google-cloud-functions-tutorial-overview-of-computing-options-3c27781e8ced
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Google Cloud Functions Tutorial : Overview of Computing Options

This is part of a Google Cloud Functions Tutorial Series. Check out the series for all the articles

This is the first part of the Cloud Functions Tutorial Series. It provides a high level overview of the Computing Options that are available in the cloud today. You might be already familiar with some of these options and might want to go over it quickly.

Let us take a look at a diagram from one of the presentations given recently:

Image for post
Image for post

The interesting thing to note over here is the entire spectrum ranging on IaaS on the left side to FaaS on the right side. All of these computing options are relevant depending on the use case and organization. The thing to note is that on the extreme left, you have more control but you need a team that is capable of managing the infrastructure. As we move towards the right side, we find that the abstractions go to a high level and the infrastructure management is taken care of by the cloud provider.

Virtual Machines on the right side are best suited to moving your existing workloads. That is precisely what the IaaS vendors give you. With the need for portability across platforms, containers have gained mindshare and great success. The CaaS Platforms primarily help you manage the containers at scale. PaaS platforms are much more restrictive in nature since they run within a sandbox, you have to code against the APIs and so on. But they are a highly productive environment from a development perspective if it meets your requirement. The Cloud Vendor takes care of most of the infrastructure management except for a few knobs that you have to tweak.

Finally, we come to FaaS (Functions as a Service), which is the central theme for this tutorial series. Functions currently represent the highest level of abstraction and hope to make it easier for everyone to understand and use them today. You package your code in the form of a ZIP file or point to where you code resides and the tooling takes care of running the functions for you. The functions are primarily executed in response to events that the Cloud Provider Services support. Not all cloud provider services might be supported as triggers to execute your functions automatically. FaaS is also gaining in importance due to the economies in running the same. You are not charged if the functions are not running. The pricing is interesting and is based on the number of invocations and the amount of memory/CPU that your function will utilize. It changes the way you think of your application.

In summary, the move is towards Serverless Architectures. Serverless is usually referred to as “No Ops” where you focus on the functionality and with minimal effort your functionality is deployed and running for you. It utilizes services that the Cloud Providers give but you do not do any of the server management. Other characteristics of Serverless Architectures would include a pricing model based on usage, High Availability, Flexible Scaling and no idle capacity.

Specifically, FaaS which stands for Functions as a Service is available since a while. Currently it is available from the big 3 cloud vendors are AWS Lambda, Azure Functions and Google Cloud Functions. There are popular FaaS distributions available for deployment even locally like OpenFaaS, Nuclio and others.

At a recent Google Cloud Community Conference, we had a great presentation on Serverless Computing and I wish to reproduce a slide from that session here that helps you think of Serverless via 3 categories:

Image for post
Image for post
Reference : Google Cloud Community Summit

Specifically if we have to map the compute offerings on Google Cloud Platform, the diagram below is another manifestation of the Computing options that are available today, which range from IaaS to FaaS.

Image for post
Image for post
Image Reference : Google Cloud Platform Official Documentation

We are specifically going to focus on FaaS (Functions as a Service) over here and will zoom in on Google Cloud Functions.

To summarize this post, we can focus now on what we exactly mean by Functions as a Service. You will probably find multiple definitions on it but I have found it more useful to look at features that we expect in a FaaS. Not all FaaS offerings might give you all the features but it will help set the context to make you understand what FaaS has to offer. I have collected these points from an excellent paper on Serverless Architectures (https://martinfowler.com/articles/serverless.html) and have listed them here for you, with some additional comments from my side.

  • Run back end code without managing your own server systems.
  • Scaling is completely managed by provider.
  • Cost based on number of invocations, memory and CPU consumption. Pay for usage and scales down to zero.
  • A Function is the smallest unit of abstraction. They are stateless. This is not to say that you cannot have state in your function but you will have to manage that separately, maybe via a Database or a Shared Memory Cache, etc.
  • Write a Function in the language of your choice (dependent on availability of Language runtime). Not all FaaS are equal when it comes to this. In fact, at the time of writing, Google Cloud Functions is in BETA and supports only JavaScript.
  • Based on familiar code that you write today.
  • Package your code locally and upload it (ZIP file, Code Repository).
  • No specific tooling needed. You could develop them in an IDE of your choice using a language runtime that is supported by the FaaS provider. The FaaS provider might give you local tools that can help you test, deploy and debug your functions locally.
  • Functions would be triggered via events in the Cloud Provider Services. For e.g. if a file uploaded to a Storage bucket or a message is published to a Topic or a row in created in a Database.
  • Functions can also be invoked directly via HTTP.
  • Functions have a limit to execution time and startup latency (cold start). All FaaS providers will time out your function if they run for more than the default timeout. This also encourages best practices to indicate that your function execution is complete since you are charged for the time that your function executes, so you want them to be kept to a minimum.

Let’s get started next with an overview of Google Cloud Functions.

Proceed to the next part : What is Google Cloud Functions or go back to the Google Cloud Functions Tutorial Home Page.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK