Google made over 122 different announcements, spanning its offerings in infrastructure, application development, data management/analytics, AI, productivity, and more.
Of particular interest to developers operating serverless platforms is the availability of Google Cloud Run. Alongside Google App Engine and Cloud Functions, Cloud Run presents additional choices for developers considering serverless deployments on Google Cloud. Let’s review why you might want to build serverless applications, compare Google’s serverless offerings, and when you should choose one over another.
The main benefit of serverless platforms is that they let you focus on writing code without worrying about managing infrastructure, auto-scaling, or paying for more than what you use.
At the developer keynote at #googlenext19 and loving the emphasis on getting to the fun part — because that’s also what delivers value.
— nicole forsgren PHD IN COMPUTERING THINGS (@nicolefv) April 10, 2019
When we leverage tooling & automation to make build/test/deploy fast and easy, people can focus on the novel & creative parts of work 💖
This makes serverless computing ideal for use cases such as:
Cloud Run, Cloud Functions, and App Engine are all serverless platforms offered by Google Cloud, but they have nuances that can make one preferable to the other in certain situations.
Built from Knative, Cloud Run is the latest of Google’s serverless offerings. While other serverless platforms use event-driven functions as the main unit of deployment, Cloud Run enables you to package code in a stateless container, then invoke it via HTTP requests.
Deploying Cloud Run containers in Google’s fully managed environment provides developers with the usual benefits of serverless (no infrastructure management, usage-based pricing, easier auto-scaling), but also supports any number of programming languages, libraries, or system binaries. Cloud Run can also deploy containers on Google Kubernetes Engine (GKE), with the ability to specifically configure hardware requirements for your serverless containers in the latter case.
With this flexibility, users of Cloud Run can easily run serverless workloads with tools they already use to package and run containers on Google Cloud, or deploy stateful and stateless workloads together.
While Cloud Run takes containers and makes them invocable via HTTP requests, Cloud Functions remain as Google’s event-driven serverless platform. As opposed to being packaged in a Docker container, you deploy code as functions. Google supports writing Cloud Functions so they can also be called via HTTP requests, or set to trigger based on background events.
def hello_get(request): """HTTP Cloud Function. Args: request (flask.Request): The request object. <http://flask.pocoo.org/docs/1.0/api/#flask.Request> Returns: The response text, or any set of values that can be turned into a Response object using `make_response` <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>. """ return 'Hello World!'
Hello World, written as an HTTP Cloud Function
Cloud Functions places more constraints on how your code is deployed (the obvious one being you need to package it as a function), and supports only a specific set of languages (you can write Cloud Functions using JavaScript/Node.js, Python 3, or Go runtimes), but offers the ability to trigger functions using events in your cloud environment.
App Engine is Google’s fully managed serverless application platform for web and API backends. While serverless functions let you easily run lightweight and standalone pieces of functionality, it can be difficult to run more complex applications using Cloud Functions. For developers who want to build a serverless application with multiple pieces of functionality, or retain some level of context that survives beyond an individual request, Google App Engine presents a compelling option.
In Google App Engine, you simply take your code and deploy it on Google, then pay for the resources you consume – this runs on App Engine as a single resource consisting of one or more services. For each service, you deploy one or more versions of that service, which in turn run within one or more instances depending on the amount of traffic each version handles.
Deploying Hello World on Google App Engine with a single command from your app’s directory, shown above
Depending on your particular needs, you can run your code in one of two types of App Engine environment. Google recommends the standard environment when you want to run an application that needs to rapidly scale, written in a specific language version that App Engine supports. For applications that experience more consistent traffic, run in Docker containers with custom runtimes or non-supported programming languages, or access parts of your Google Platform project that run on Compute Engine, choose the App Engine Flexible Environment instead.
In general, serverless platforms are best used to build stateless applications without needing to manage infrastructure. Some examples include:
When deciding which of these serverless platforms is right for you, keep the following points in mind:
Google also provides a handy flowchart that you can find here, along with example use cases for each.
We’re incredibly excited by Google’s latest announcements around serverless computing, and in a broader sense, how serverless helps developers push the pace of software innovation. To learn specifically about monitoring serverless workloads on Google Cloud, you can read about how Splunk Infrastructure Monitoring provides real-time visibility for Knative, Cloud Run, and Google Cloud Functions.
If you’re not already using Splunk Infrastructure Monitoring, get started with a 14-day trial or observability demo.
Thanks,
Aaron Sun
The Splunk platform removes the barriers between data and action, empowering observability, IT and security teams to ensure their organizations are secure, resilient and innovative.
Founded in 2003, Splunk is a global company — with over 7,500 employees, Splunkers have received over 1,020 patents to date and availability in 21 regions around the world — and offers an open, extensible data platform that supports shared data across any environment so that all teams in an organization can get end-to-end visibility, with context, for every interaction and business process. Build a strong data foundation with Splunk.