Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Google Cloud Serverless

Introduction to Google Cloud Serverless

Introducing Cloud Functions, Cloud Run, and Cloud Scheduler

Mete Atamel

May 22, 2023
Tweet

More Decks by Mete Atamel

Other Decks in Technology

Transcript

  1. Operational Model No Infra Management Managed Security Pay only for

    usage Programming Model Service-based Event-driven Stateless Serverless
  2. The serverless landscape in Google Cloud Cloud Run Run HTTP

    or run-to-completion containers Cloud Functions Run HTTP and event-triggered functions Cloud Build Serverless CI/CD Build & Run Cloud Workflows Service orchestration Cloud Tasks HTTP task queue Eventarc Route events from source to destination Cloud Scheduler Cron for the cloud Orchestrate Cloud Pub/Sub Publish/subscribe events to/from topics API Gateway API routing and management VPC Access Serverless networking Connect App Engine Run web applications in a fully managed environment Serverless 1.0 Serverless 2.0
  3. Proprietary + Confidential Virtual Machine OS Application Runtime Application Virtual

    Hardware Container OS Application Runtime Application Virtual Hardware Functions Functions Application OS Application Runtime Application Virtual Hardware Functions Function OS Application Runtime Application Virtual Hardware Functions Compute Engine Kubernetes Engine App Engine Cloud Functions Serverless Zone Container OS Application Runtime Application Virtual Hardware Functions Cloud Run
  4. 5 Serverless Functions Single-purpose autoscaled functions Deploy from source. Autoscales

    up and down. Based on OSS Functions Framework Run locally or in the cloud easily Triggered by HTTP or CloudEvents Sync with HTTP, async with OSS CloudEvents Supports popular languages Node.js, Python, Go, Java, PHP, Ruby, .NET Autoscaled, Concurrency, Auto HTTPS/TLS, IAM/Org Policy Cloud Functions func helloWorld() Eventarc Pub/Sub https:// Source code Trigger with events from Google Cloud and 3rd party providers Trigger with a message to a queue Trigger with a request Cloud Scheduler Trigger on a schedule
  5. 1. Certain versions of certain languages are supported • Node.js

    8, 10, 12, 14, 16, 18, 20 (preview) • Python 3.7, 3.8, 3.9, 3.10, 3.11 • Go 1.11, 1.13, 1.16, 1.18, 1.19, 1.20 • Java 11, 17 • .NET Core 3.1, .NET 6 • PHP 7.4, 8.1, 8.2 • Ruby 2.6, 2.7, 3.0, 3.2 2. One HTTP path / event per function Limitations
  6. What to do when Cloud Functions is not enough? Create

    your own runtime with containers!
  7. Containers Any language Any library You get to build your

    own runtime .js .rb .go .py .sh … 0 1 0 1 0 0 1 1 1
  8. Serverless containers with Knative and Cloud Run Cloud Run Serverless

    containers, fully managed, no cluster Cloud Run on GKE/Anthos Serverless containers on GKE/Anthos in Google Cloud Knative everywhere Serverless containers on everywhere you run Kubernetes
  9. Cloud Run Serverless Containers Deploy source, Dockerfile or images Uses

    OSS buildbacks and Cloud Build, integrates with Artifact Registry or Docker Hub Autoscaled HTTP services Web apps, APIs & internal apps Parallel background & batch jobs with Cloud Run jobs No cluster management Based on Knative, portable to Kubernetes Autoscaled, Concurrency, Auto HTTPS/TLS, IAM/Org Policy const express = require('express'); const app = express(); https:// Source code / Dockerfile Trigger with Eventarc / PubSub / Scheduler Trigger with a HTTP/gRPC/Websocket Container Image Cloud Run services async function main() { ... } Source code / Dockerfile Trigger on a schedule Container Image Trigger via API Cloud Run jobs
  10. Proprietary + Confidential Container contract & resources • Listen on

    0.0.0.0 on port $PORT (default 8080) • HTTP server must start < 4 min (timeout → 504) • Request time < 5 min (default → 5 min, up to 60 min) • Stateless (in-memory file system) • Computation only within request (Unless always-CPU is enabled) • 1 vCPU per container instance (configurable to 8 vCPU) • 256 MiB of memory up to a max of 8 GiB (configurable to 32 GiB) • 80 concurrent requests per container (configurable to 1000) • 100 max containers by default (configurable 1-1000, support overridable) • Sandboxed by gVisor • Ability to listen on multiple paths
  11. Concurrency + min instances = Much improved cold start concurrency

    = 1 concurrency = 80 (default) - 1000 (max) Cloud Functions (gen1) Cloud Functions (gen2) Cloud Run
  12. Proprietary + Confidential 13 Cloud Scheduler Use Cloud Scheduler to

    setup a cron job in the cloud based on a schedule Cron in the Cloud Cloud Scheduler Cloud Run job Cloud Run Cloud Run service Cloud Run Serverless function Cloud Function Pub/Sub topic Pub/Sub Workflows HTTP Workflows App Engine HTTP App Engine …
  13. Thank you! Mete Atamel Developer Advocate at Google @meteatamel atamel.dev

    speakerdeck.com/meteatamel github.com/meteatamel/cloud-code-custom-templates github.com/GoogleCloudPlatform/jobs-demos/tree/main/screenshot Feedback? bit.ly/atamel