Slide 1

Slide 1 text

What’s new in Serverless on Google Cloud Platform

Slide 2

Slide 2 text

Guillaume Laforge Developer Advocate Google Cloud @glaforge

Slide 3

Slide 3 text

@glaforge Google Cloud Platform

Slide 4

Slide 4 text

@glaforge A big global network of data centers https://cloud.google.com/about/locations/

Slide 5

Slide 5 text

@glaforge Machine Learning Cloud ML Platform Vision API Video Intelligence API Speech API Translate API NLP API Compute Compute Engine App Engine Kubernetes Engine Container Registry Cloud Run Cloud Functions Networking Cloud Virtual Network Cloud Load Balancing Cloud CDN Cloud Interconnect Cloud DNS Storage & Databases Cloud Storage Cloud Bigtable Cloud Datastore Cloud SQL Cloud Spanner Big Data BigQuery Cloud Dataflow Cloud Dataproc Cloud Dataprep Cloud Datalab Cloud Pub/Sub Genomics Management Stackdriver Overview Monitoring Logging Error Reporting Debugger Deployment Manager Developer Cloud SDK Deployment Manager Cloud Source Repositories Cloud Endpoints Cloud Tools for Android Studio Cloud Tools for IntelliJ Google Plugin for Eclipse Cloud Test Lab Cloud Container Builder Identity & Security Cloud IAM Cloud IAP Cloud KMS Cloud Resource Manager Cloud Security Scanner Cloud Platform Security Overview Panorama

Slide 6

Slide 6 text

@glaforge Not Google’s new serverless data center

Slide 7

Slide 7 text

@glaforge Serverless model(s) Operational Model Programming Model No Infra Management Managed Security Pay only for usage Service-based Event-driven Open

Slide 8

Slide 8 text

@glaforge The Serverless spectrum

Slide 9

Slide 9 text

@glaforge Serverless operational spectrum Managed by your cloud Container orchestration (k8s) Not serverless for programming or ops Container focused Infra managed by you Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless anywhere Knative / Cloud Run on GKE On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed

Slide 10

Slide 10 text

@glaforge Serverless “compute” on Cloud Platform App Engine Standard Highly scalable, serverless web applications. Deploy and scale Applications that react to Requests Cloud Functions Event-driven serverless compute platform. Deploy and scale Functions that react to Events Cloud Run Highly scalable, serverless stateless containers. Deploy and scale Containers that react to Requests

Slide 11

Slide 11 text

@glaforge Demo: Sharing pictures

Slide 12

Slide 12 text

@glaforge Demo: Sharing pictures pic-a-daily.appspot.com

Slide 13

Slide 13 text

@glaforge Demo: Sharing pictures Event-driven logic Data storage User facing Frontend Web + API Admin app Picture files Picture metadata & most frequent tags Vision API annotations: Labels, color, filtering Via Pub/sub Compute most popular tags pic-a-daily.appspot.com

Slide 14

Slide 14 text

@glaforge So what did we launch?

Slide 15

Slide 15 text

@glaforge New idiomatic App Engine runtimes ○ Python 3.7 (GA) ○ PHP 7.3 (GA) ○ Go 1.12 (GA) ○ Node.js 10 (GA) ○ Java 8 (11 in beta) ○ Ruby 2.5 (in alpha)

Slide 16

Slide 16 text

@glaforge Double the memory! 2x

Slide 17

Slide 17 text

@glaforge App Engine Java 11 (beta) ● Executable JAR support ○ Servlet containers not required ○ Choose your favorite web framework & libs ● Custom entrypoint ○ Full control on how to start your application ○ Graal VM executables possible ● More idiomatic ○ No more class whitelist ○ Runs in a gVisor based secured sandbox

Slide 18

Slide 18 text

@glaforge ○ General Availability with SLA ○ Go, Node & Python ■ Java in alpha ○ Security & scaling controls ○ Environment Variables Cloud Functions

Slide 19

Slide 19 text

@glaforge New Go 1.11 runtime (1.12 in alpha)

Slide 20

Slide 20 text

@glaforge Go 1.11, vendor & module friendly package hello import ( "fmt" "net/http" ) func HelloWorld(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, World!") } $ gcloud beta functions deploy hello --entry-point HelloWorld --runtime go111 --trigger-http

Slide 21

Slide 21 text

@glaforge Node 8 with async / await const PubSub = require('@google-cloud/pubsub'); exports.helloPubSub = async (data, context) => { let ps = new PubSub(); try { const topicName = context.resource.name; const topic = ps.topic(topicName); const data = await topic.getMetadata(); const metadata = data[0]; console.log(`Metadata: ${JSON.stringify(metadata)}`); } catch(err) { console.error(err); } };

Slide 22

Slide 22 text

@glaforge Java HTTP functions import javax.servlet.http.*; import java.io.*; public class Example { public void helloWorld(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write("Hello world!"); }

Slide 23

Slide 23 text

@glaforge Java background functions — Pub/Sub import java.util.*; import java.util.logging.Logger; public class Example { public void helloPubSub(PubSubMessage message) throws Exception { String data = new String(Base64.getDecoder() .decode(message.data.getBytes("UTF-8"))); // do something with data } class PubSubMessage { String data; Map attributes; String messageId; String publishTime; }

Slide 24

Slide 24 text

@glaforge Environment variables $ gcloud beta functions deploy fnNAme --set-env-vars FOO=bar $ gcloud beta functions deploy fnNAme --env-vars-file .env.yaml --update-env-vars FOO=baz --remove-env-vars FOO --clear-env-vars

Slide 25

Slide 25 text

@glaforge Function scaling control Limit scaling on a per-function basis Prevents DoSing resources with different scalability $ gcloud functions deploy --max-instances=100

Slide 26

Slide 26 text

@glaforge Security controls Control access to function invocation using IAM ● Developers ● Other functions or GCP services ● End-users using Google Sign-In Set IAM policies on individual functions Private by default

Slide 27

Slide 27 text

@glaforge Security controls $ gcloud functions add-iam-policy-binding fnOne \ --member='allUsers' \ --role='roles/cloudfunctions.invoker' $ gcloud functions add-iam-policy-binding fnTwo \ --member='[email protected]' \ --role='roles/cloudfunctions.invoker'

Slide 28

Slide 28 text

@glaforge Per function identities By default, all functions share the same identity Identity can be set on a per-function basis to provide least privilege access

Slide 29

Slide 29 text

@glaforge Per function identities $ gcloud iam service-accounts create fnOne $ gcloud iam service-accounts add-iam-policy-binding \ [email protected] \ --member='serviceAccount:[email protected]' \ --role='roles/cloudfunctions.invoker' $ gcloud functions deploy fnOne \ --service-account [email protected]

Slide 30

Slide 30 text

@glaforge Per function identities $ gcloud iam service-accounts create fnTwo $ gcloud iam service-accounts add-iam-policy-binding \ [email protected] \ --member='serviceAccount:[email protected]' \ --role='roles/cloudsql.client' $ gcloud functions deploy fnTwo \ --service-account [email protected]

Slide 31

Slide 31 text

@glaforge Cloud Run Serverless Containers

Slide 32

Slide 32 text

@glaforge Everything at Google runs in containers: Gmail, Web Search, Maps, ... MapReduce, batch, ... GFS, Colossus, ... Even GCE itself: VMs in containers Google launches 4 billion containers per week.

Slide 33

Slide 33 text

@glaforge Serverless operational spectrum Managed by your cloud Container orchestration (k8s) Not serverless for programming or ops Container focused Infra managed by you Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless anywhere Knative / Cloud Run on GKE On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed Serverless containers Custom languages & runtimes Infra still cloud-managed New!

Slide 34

Slide 34 text

Serverless agility for containerized apps Cloud Run One experience, where you want it One developer experience Fully managed or Your GKE cluster Consistent APIs & tooling Portable with Knative Without vendor lock-in Natively Serverless No servers to manage Focus on writing code Scale up fast Scale down to zero Pay for exact usage Container to production in seconds Just "deploy" Any stateless container Any language, any library URL in seconds

Slide 35

Slide 35 text

Cloud Run — Container contract ● Stateless ○ Don’t store data in a database ○ Only an in-memory file system ● HTTP payloads ○ Listen on 0.0.0.0 on port $PORT ○ Start an HTTP in < 4 minutes ● Concurrency ○ Up to 80 concurrent requests ● Linux 64 bit binaries ○ x86_64 ABI format

Slide 36

Slide 36 text

Cloud Run — Pay per use CPU / Memory / Requests 100ms

Slide 37

Slide 37 text

@glaforge Knative Cloud Run on GKE

Slide 38

Slide 38 text

@glaforge Serverless operational spectrum Managed by your cloud Container orchestration (k8s) Not serverless for programming or ops Container focused Infra managed by you Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless anywhere Knative / Cloud Run on GKE On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed New! Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra

Slide 39

Slide 39 text

Cloud Run — Managed vs on GKE Cloud Run (fully managed) • Fully serverless • No cluster to manage, minimal ops • Pay for what you use • Limited instance sizes Cloud Run on GKE • Serverless developer experience • Runs in your GKE cluster, K8S ops • Custom machine types (CPU/GPU/Mem)

Slide 40

Slide 40 text

@glaforge Knative — Serverless building blocks on Kubernetes Kubernetes-based building blocks for serverless workloads Build Serving Events

Slide 41

Slide 41 text

@glaforge Knative — Partners

Slide 42

Slide 42 text

@glaforge Cloud Run on GKE with Knative

Slide 43

Slide 43 text

@glaforge $ gcloud run deploy --image gcr.io/... Deploy on Cloud Run

Slide 44

Slide 44 text

@glaforge $ gcloud run deploy --image gcr.io/... --cluster my-cluster Deploy on Cloud Run on GKE

Slide 45

Slide 45 text

@glaforge Icing on the planet cake

Slide 46

Slide 46 text

@glaforge Cloud Tasks ● Manage distributed task queues ● Decouple and scale microservices ● Manage resource consumption ● Handle releases gracefully cloud.google.com/tasks/ New!

Slide 47

Slide 47 text

@glaforge Cloud Scheduler ● Enterprise grade cron job scheduler ● Schedule batch, big data jobs, cloud infra ops... ○ Invoke Cloud Functions over HTTPS or Pub/Sub ○ Invoke App Engine on a relative url handler ● Manage all your jobs from one place cloud.google.com/scheduler New!

Slide 48

Slide 48 text

@glaforge Q & A Serverless on Google Cloud Platform cloud.google.com/serverless App Engine Java 11 cloud.google.com/appengine/docs/standard/java11/ Cloud Functions Java beta bit.ly/gcf-java Cloud Run cloud.run Knative github.com/knative

Slide 49

Slide 49 text

@glaforge Serverless on Google Cloud Platform cloud.google.com/serverless App Engine Java 11 cloud.google.com/appengine/docs/standard/java11/ Cloud Functions Java beta bit.ly/gcf-java Cloud Run cloud.run Knative github.com/knative Thank you / Q & A