SlideShare a Scribd company logo
Designing flexible apps deployable to App
Engine, Cloud Functions, or Cloud Run
Wesley Chun - @wescpy
Developer Advocate, Google
Adjunct CS Faculty, Foothill College
Developer Advocate, Google Cloud
● Mission: enable current and future
developers everywhere to be
successful using Google Cloud and
other Google developer tools & APIs
● Focus: GCP serverless (App Engine,
Cloud Functions, Cloud Run); higher
education, Google Workspace, GCP
AI/ML APIs; multi-product use cases
● Content: speak to developers globally;
make videos, create code samples,
produce codelabs (free, self-paced,
hands-on tutorials), publish blog posts
About the speaker
Previous experience / background
● Software engineer & architect for 20+ years
○ Yahoo!, Sun, HP, Cisco, EMC, Xilinx
○ Original Yahoo!Mail engineer/SWE
● Technical trainer, teacher, instructor
○ Taught Math, Linux, Python since 1983
○ Private corporate trainer
○ Adjunct CS Faculty at local SV college
● Python community member
○ Popular Core Python series author
○ Python Software Foundation Fellow
● AB (Math/CS) & CMP (Music/Piano), UC
Berkeley and MSCS, UC Santa Barbara
● Adjunct Computer Science Faculty, Foothill
College (Silicon Valley)
Why & agenda
1
Introduction
2
Google Cloud
Serverless review
3
Nebulous, flexible
app(s)
4
Deployments
5
Summary
● Cloud computing has taken industry by storm (all?)
● App modernization top priority/key goal at many enterprises
○ Containerize apps, get them on VMs, move to cloud
● Serverless: let users focus on solutions not what they run on
● GCP: 3 (4) different serverless products for different use cases
● Similar yet different from each other, but flexible apps deployable to all
● Help prep next-generation (cloud-ready) workforce
01
Introduction
Why are you here?
Serverless: what & why
● What is serverless?
○ Misnomer (a "PMM") :-)
○ "No worries"
○ Developers focus on writing code & solving business problems*
● Why serverless?
○ Fastest growing segment of cloud... per analyst research*:
■ $1.9B (2016) and $4.25B (2018) ⇒ $7.7B (2021) and $14.93B (2023)
○ What if you go viral? Autoscaling: your new best friend
○ What if you don't? Code not running? You're not paying.
* in USD; source:Forbes (May 2018), MarketsandMarkets™ & CB Insights (Aug 2018)
Serverless with Google
Operational
Model
Programming
Model
Low infra management Managed security Pay only for usage
Service-based
monoliths
Request +
event-driven
Open
Google Compute Engine, Google Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google BigQuery, Cloud SQL,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Serverless: PaaS-y compute/processing
Google Apps Script
Salesforce1/force.com
cloud.google.com/hosting-options#hosting-options
Google Cloud compute option spectrum
Compute
Engine
Kubernetes
Engine (GKE)
Cloud Run
on Anthos
Cloud Run
(fully-mgd)
App Engine
(Flexible)
App Engine
(Standard)
Cloud
Functions
Serverless common use cases App Engine Cloud Run
Cloud
Functions
Web services
Web app hosting/custom domains ✓ ✓
HTTP services ✓ ✓ ✓
Container hosting ✓
APIs
Web & mobile backends ✓ ✓
Internal APIs and services ✓ ✓
Data processing ✓ ✓
Automation
Workflow & orchestration ✓ ✓
Event-driven automation ✓ ✓
Common use cases
02
Google Cloud
serverless
...compute platforms review
Google App Engine
App-hosting in the cloud
Why does App Engine exist?
● Focus on app not DevOps
○ Web app
○ Mobile backend
○ Cloud service
● Enhance productivity
● Deploy globally
● Fully-managed
● Auto-scaling
● Pay-per-use
● Familiar languages
● Test w/local dev server
App Engine to the rescue!!
● Focus on app not DevOps
● Enhance productivity
● Deploy globally
● Fully-managed
● Auto-scaling
● Pay-per-use
● Familiar standard runtimes
● 2nd gen std platforms
○ Python 3.7
○ Java 8, 11
○ PHP 7.2
○ Go 1.11
○ JS/Node.js 8, 10
○ Ruby 2.5
Hello World (Python "MVP")
app.yaml
runtime: python38
main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
requirements.txt
Flask==1.1.2
Deploy:
$ gcloud app deploy
Access globally:
PROJECT_ID.appspot.com
cloud.google.com/appengine/docs/standard/python3/quickstart
Google Cloud Functions
Function-hosting in the cloud
Why does Cloud Functions exist?
● Don't have entire app?
○ No framework "overhead" (LAMP, MEAN...)
○ Deploy microservices
● Event-driven
○ Triggered via HTTP or background events
■ Pub/Sub, Cloud Storage, Firebase, etc.
○ Auto-scaling & highly-available; pay per use
● Flexible development environment
○ Cmd-line or developer console (in-browser)
○ Develop/test locally with Functions Framework
● Cloud Functions for Firebase
○ Mobile app use-cases
● Available runtimes
○ JS/Node.js 8, 10, 12, 14
○ Python 3.7, 3.8, 3.9
○ Go 1.11, 1.13
○ Java 11
○ Ruby 2.6, 2.7
○ .NET Core 3.1
main.py
def hello_world(request):
return 'Hello World!'
Deploy:
$ gcloud functions deploy hello --runtime python38 --trigger-http
Access globally (curl):
$ curl REGION-PROJECT_ID.cloudfunctions.net/hello
Access globally (browser):
https://REGION-PROJECT_ID.cloudfunctions.net/hello
Hello World (Python "MVP")
cloud.google.com/functions/docs/quickstart-python
Google Cloud Run
Container-hosting in the cloud
The rise of containers... ● Any language
● Any library
● Any binary
● Ecosystem of base images
● Industry standard
FLEXIBILITY
“We can’t be locked in.”
“How can we use
existing binaries?”
“Why do I have to choose between
containers and serverless?”
“Can you support language _______ ?”
Serverless inaccessible for some...
CONVENIENCE
Cloud Run: code, build, deploy
.js .rb .go
.sh
.py ...
● Any language, library, binary
○ HTTP port, stateless
● Bundle into container
○ Build w/Docker OR
○ Google Cloud Build
○ Image ⇒ Container Registry
● Deploy to Cloud Run (managed or GKE)
● GitOps: (CI/)CD Push-to-deploy from Git
State
HTTP
Hello World (Python "MVP")
main.py
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))
cloud.google.com/run/docs/quickstarts/build-and-deploy
requirements.txt
Flask==1.1.2
Hello World (Python "MVP")
Dockerfile
FROM python:3-slim
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "main.py"]
.dockerignore
Dockerfile
README.md
*.pyc
*.pyo
.git/
__pycache__
Build (think docker build and docker push) then deploy (think docker run):
$ gcloud builds submit --tag gcr.io/PROJ_ID/IMG_NAME
$ gcloud run deploy SVC_NAME --image gcr.io/PROJ_ID/IMG_NAME
OR… Build and Deploy (1-line combo of above commands):
$ gcloud run deploy SVC_NAME --source .
Access globally:
SVC_NAME-HASH-REG_ABBR.a.run.app
Docker &
Dockerfile
OPTIONAL!!
● Build containers easily & securely without creating/managing Dockerfiles
● Open source, open standard; based on CNCF Buildpacks spec v3
● Used by GCF Functions Framework to deploy locally-developed functions
● Supports most common development tools
○ Go 1.10+
○ Node.js 10+
○ Python 3.7+
○ Java 8 & 11
○ .NET Core 3.1+
● Blog posts
○ cloud.google.com/blog/products/containers-kubernetes/google-cloud-now-supports-buildpacks and
cloud.google.com/blog/products/serverless/build-and-deploy-an-app-to-cloud-run-with-a-single-command
Deploy to Cloud Run with Buildpacks
github.com/GoogleCloudPlatform/buildpacks
$ ls
index.js package.json
$ gcloud run deploy myapp --source .
$ ls
app.py requirements.txt
$ gcloud run deploy myapp --source .
03
Nebulous, flexible app(s)
Deployable to all platforms
Flexibility in options
Cloud
Functions
App
Engine
Cloud
Run
local
server
Cloud
Translation
My "Google Translate" MVP
github.com/googlecodelabs/cloud
-nebulous-serverless-python
● "Nebulous" sample web app
○ Flask/Python app
○ Python 2 & 3 compatible
○ Uses Cloud Translation API
● Deployable to on-prem server
● Also GCP serverless compute
○ App Engine
○ Cloud Functions
○ Cloud Run
● With only config changes
● No changes to app code
Nebulous files
● Application files
● Configuration files
● Administrative files
○ Information files
○ Testing - CI/CD files
● Files differ per deployment
● Mainly in configuration
● Application files identical
● Administrative files not part of
deployments*
Different nebulous deployments
1. Local (or hosted) Flask server (Python 2)
2. Local (or hosted) Flask server (Python 3)
3. Google App Engine (Python 2)
4. Google App Engine (Python 3)
5. Google Cloud Functions (Python 3)
6. Google Cloud Run (Python 2 via Docker)
7. Google Cloud Run (Python 3 via Docker)
8. Google Cloud Run (Python 3 via Cloud Buildpacks)
04
Deployments
& required configuration tweaks
Local (Flask)
● Python 2 or 3
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt (install locally; see below)
○ Service acct pub/prv key-pair & download (credentials.json)
○ Point $GOOGLE_APPLICATION_CREDENTIALS env var to ^^^^
● Run pip install -U pip -r requirements.txt
● Run python main.py
Google App Engine
● Python 2
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt (install locally; see below)
○ app.yaml
○ appengine_config.py
● Run pip install -t lib -r requirements.txt
● Run gcloud app deploy
Google App Engine
● Python 3
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt
○ app.yaml (uncomment runtime: python38)
● Run gcloud app deploy
Google Cloud Functions
● Python 3
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt
● Run gcloud functions deploy translate --runtime python37
--trigger-http --allow-unauthenticated
Google Cloud Run (Docker)
● Python 2
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt (uncomment gunicorn)
○ Dockerfile (replace ENTRYPOINT with gunicorn)
● Run gcloud beta run deploy translate
--allow-unauthenticated --platform managed --source .
Google Cloud Run (Docker)
● Python 3
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt (uncomment gunicorn)
○ Dockerfile (use Py3 base image & gunicorn ENTRYPOINT)
● Run gcloud beta run deploy translate
--allow-unauthenticated --platform managed --source .
Google Cloud Run (Cloud Buildpacks)
● Python 3
● Application files
○ main.py and templates/index.html
● Config files
○ requirements.txt (uncomment gunicorn)
○ Procfile (replace web: with gunicorn)
● Run gcloud beta run deploy translate
--allow-unauthenticated --platform managed --source .
05
Summary
Resources & conclusion
Possible courses for this sample app
● Software Engineering
● Intro to Cloud Computing
● Machine Learning/AI
● Web application development
● Mobile app (backends)
○ Suggest Cloud Functions for Firebase (vs. GCF)
● Data science/big data
● Business applications
Cost of Google Cloud serverless tools
● What is free in Google Cloud overall?
○ Free Trial (credit card required; expires)
■ $300USD credit good for first 90 days
○ Always Free tier (credit card required; no expiration; subject to change)
■ Independent of Free Trial & education grants (more below)
■ Some GCP products free up to usage limits
○ Learn about both programs at cloud.google.com/free
● Serverless Always Free tier (monthly)
○ App Engine (28 [or 9] hours, 1GB storage & 1GB egress) per day
○ Cloud Run (2M reqs, 350k GB-secs, 180k vCPU-secs, 1GB egress) per month
○ Cloud Functions (2M calls, 400k GB-secs, 200k vCPU-secs, 5GB egress) per month
● Higher education (teaching & research) grants
○ cloud.google.com/edu (credit card NOT required; expires)
○ Provides "free" usage for coursework and initial research
$$ FREE $$
Session summary
● What's the right tool for the job?
○ GAE, GCF, GCR: they've got different use cases
○ Goal: gain familiarity with all three (learn their differences)
○ They're not as different as you may think!
● One nebulous, flexible sample web app
○ Mini "My Google Translate MVP" featuring Cloud Translation API
○ Deployable to all serverless compute platforms
○ Only requires configuration changes
○ KISS: use default service account credentials
○ github.com/googlecodelabs/cloud-nebulous-serverless-python
Other Google APIs & platforms
● Google Workspace (G Suite) (code Gmail, Drive, Docs, Sheets, Slides!)
○ developers.google.com/gsuite
● Firebase (mobile development platform and RT DB plus ML-Kit)
○ firebase.google.com and firebase.google.com/docs/ml-kit
● Google Data Studio (data visualization, dashboards, etc.)
○ datastudio.google.com/overview
○ goo.gle/datastudio-course
● Actions on Google/Assistant/DialogFlow (voice apps)
○ developers.google.com/actions
● YouTube (Data, Analytics, and Livestreaming APIs)
○ developers.google.com/youtube
● Google Maps (Maps, Routes, and Places APIs)
○ developers.google.com/maps
● Flutter (native apps [Android, iOS, web] w/1 code base[!])
○ flutter.dev
Invite me (or my team) to
your campus... it's our job!
● Faculty & grad students
● Researchers
● Undergrads
● University IT staff/CIO/CTO
● University entrepreneurship
centers/capstone project leads
Thank you! Questions?
Wesley Chun
@wescpy
Progress bars: goo.gl/69EJVw

More Related Content

What's hot (20)

PDF
Easy path to machine learning (Spring 2021)
wesley chun
 
PDF
Build with ALL of Google Cloud
wesley chun
 
PDF
Google's serverless journey: past to present
wesley chun
 
PDF
Introduction to serverless computing on Google Cloud
wesley chun
 
PDF
Easy path to machine learning (Spring 2020)
wesley chun
 
PDF
Google App Engine Overview and Update
Chris Schalk
 
PDF
Building Kick Ass Video Games for the Cloud
Chris Schalk
 
PDF
How to build Kick Ass Games in the Cloud
Chris Schalk
 
PDF
How Google Cloud Platform can help in the classroom/lab
wesley chun
 
PDF
Building Integrated Applications on Google's Cloud Technologies
Chris Schalk
 
PDF
Rapid and Reliable Developing with HTML5 & GWT
Manuel Carrasco Moñino
 
PDF
Building Integrated Applications on Google's Cloud Technologies
Chris Schalk
 
PDF
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
PDF
Google Platform Overview (April 2014)
Ido Green
 
PDF
Using Google (Cloud) APIs
wesley chun
 
PDF
Deep dive into serverless on Google Cloud
Bret McGowen - NYC Google Developer Advocate
 
KEY
Google App Engine Java, Groovy and Gaelyk
Guillaume Laforge
 
PDF
Building Translate on Glass
Trish Whetzel
 
PPTX
Rapid Application Development on Google App Engine for Java
Kunal Dabir
 
PDF
Cloud Spin - building a photo booth with the Google Cloud Platform
Bret McGowen - NYC Google Developer Advocate
 
Easy path to machine learning (Spring 2021)
wesley chun
 
Build with ALL of Google Cloud
wesley chun
 
Google's serverless journey: past to present
wesley chun
 
Introduction to serverless computing on Google Cloud
wesley chun
 
Easy path to machine learning (Spring 2020)
wesley chun
 
Google App Engine Overview and Update
Chris Schalk
 
Building Kick Ass Video Games for the Cloud
Chris Schalk
 
How to build Kick Ass Games in the Cloud
Chris Schalk
 
How Google Cloud Platform can help in the classroom/lab
wesley chun
 
Building Integrated Applications on Google's Cloud Technologies
Chris Schalk
 
Rapid and Reliable Developing with HTML5 & GWT
Manuel Carrasco Moñino
 
Building Integrated Applications on Google's Cloud Technologies
Chris Schalk
 
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
Google Platform Overview (April 2014)
Ido Green
 
Using Google (Cloud) APIs
wesley chun
 
Deep dive into serverless on Google Cloud
Bret McGowen - NYC Google Developer Advocate
 
Google App Engine Java, Groovy and Gaelyk
Guillaume Laforge
 
Building Translate on Glass
Trish Whetzel
 
Rapid Application Development on Google App Engine for Java
Kunal Dabir
 
Cloud Spin - building a photo booth with the Google Cloud Platform
Bret McGowen - NYC Google Developer Advocate
 

Similar to Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run (20)

PDF
Accessing Google Cloud APIs
wesley chun
 
PDF
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
 
PDF
Serverless computing with Google Cloud
wesley chun
 
PDF
Exploring Google APIs with Python
wesley chun
 
PDF
Powerful Google developer tools for immediate impact! (2023-24 A)
wesley chun
 
PDF
Programming for non tech entrepreneurs
Rodrigo Gil
 
PDF
Web App Prototypes with Google App Engine
Vlad Filippov
 
PDF
Google... more than just a cloud
wesley chun
 
PDF
Exploring Google (Cloud) APIs & Cloud Computing overview
wesley chun
 
PDF
Cloud computing overview & Technical intro to Google Cloud
wesley chun
 
PDF
Google app-engine-with-python
Deepak Garg
 
PDF
From zero to Google APIs: Beyond search & AI... leverage all of Google
wesley chun
 
PDF
Google Cloud Platform Update
Ido Green
 
PDF
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
PDF
Odo improving the developer experience on OpenShift - hack & sangria
Jorge Morales
 
PPTX
Google Developers Overview Deck 2015
Houssem Eddine LASSOUED
 
PPTX
Instant developer onboarding with self contained repositories
Yshay Yaacobi
 
PDF
Google Apps Script: Accessing G Suite & other Google services with JavaScript
wesley chun
 
PPTX
Google App Engine for PHP
Eric Johnson
 
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Accessing Google Cloud APIs
wesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
 
Serverless computing with Google Cloud
wesley chun
 
Exploring Google APIs with Python
wesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 A)
wesley chun
 
Programming for non tech entrepreneurs
Rodrigo Gil
 
Web App Prototypes with Google App Engine
Vlad Filippov
 
Google... more than just a cloud
wesley chun
 
Exploring Google (Cloud) APIs & Cloud Computing overview
wesley chun
 
Cloud computing overview & Technical intro to Google Cloud
wesley chun
 
Google app-engine-with-python
Deepak Garg
 
From zero to Google APIs: Beyond search & AI... leverage all of Google
wesley chun
 
Google Cloud Platform Update
Ido Green
 
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
Odo improving the developer experience on OpenShift - hack & sangria
Jorge Morales
 
Google Developers Overview Deck 2015
Houssem Eddine LASSOUED
 
Instant developer onboarding with self contained repositories
Yshay Yaacobi
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
wesley chun
 
Google App Engine for PHP
Eric Johnson
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Ad

More from wesley chun (10)

PDF
Deploy Basic AI web apps with Serverless Computing from Google Cloud
wesley chun
 
PDF
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
 
PDF
Easy path to machine learning (2023-2024)
wesley chun
 
PDF
Powerful Google developer tools for immediate impact! (2023-24 B)
wesley chun
 
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
PDF
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
wesley chun
 
PDF
Serverless Computing with Python
wesley chun
 
PDF
Easy path to machine learning (2022)
wesley chun
 
PDF
Google Cloud @ Hackathons (2020)
wesley chun
 
PDF
Easy path to machine learning
wesley chun
 
Deploy Basic AI web apps with Serverless Computing from Google Cloud
wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
 
Easy path to machine learning (2023-2024)
wesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 B)
wesley chun
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
wesley chun
 
Serverless Computing with Python
wesley chun
 
Easy path to machine learning (2022)
wesley chun
 
Google Cloud @ Hackathons (2020)
wesley chun
 
Easy path to machine learning
wesley chun
 
Ad

Recently uploaded (20)

PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 

Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run

  • 1. Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run Wesley Chun - @wescpy Developer Advocate, Google Adjunct CS Faculty, Foothill College Developer Advocate, Google Cloud ● Mission: enable current and future developers everywhere to be successful using Google Cloud and other Google developer tools & APIs ● Focus: GCP serverless (App Engine, Cloud Functions, Cloud Run); higher education, Google Workspace, GCP AI/ML APIs; multi-product use cases ● Content: speak to developers globally; make videos, create code samples, produce codelabs (free, self-paced, hands-on tutorials), publish blog posts About the speaker Previous experience / background ● Software engineer & architect for 20+ years ○ Yahoo!, Sun, HP, Cisco, EMC, Xilinx ○ Original Yahoo!Mail engineer/SWE ● Technical trainer, teacher, instructor ○ Taught Math, Linux, Python since 1983 ○ Private corporate trainer ○ Adjunct CS Faculty at local SV college ● Python community member ○ Popular Core Python series author ○ Python Software Foundation Fellow ● AB (Math/CS) & CMP (Music/Piano), UC Berkeley and MSCS, UC Santa Barbara ● Adjunct Computer Science Faculty, Foothill College (Silicon Valley)
  • 2. Why & agenda 1 Introduction 2 Google Cloud Serverless review 3 Nebulous, flexible app(s) 4 Deployments 5 Summary ● Cloud computing has taken industry by storm (all?) ● App modernization top priority/key goal at many enterprises ○ Containerize apps, get them on VMs, move to cloud ● Serverless: let users focus on solutions not what they run on ● GCP: 3 (4) different serverless products for different use cases ● Similar yet different from each other, but flexible apps deployable to all ● Help prep next-generation (cloud-ready) workforce 01 Introduction Why are you here?
  • 3. Serverless: what & why ● What is serverless? ○ Misnomer (a "PMM") :-) ○ "No worries" ○ Developers focus on writing code & solving business problems* ● Why serverless? ○ Fastest growing segment of cloud... per analyst research*: ■ $1.9B (2016) and $4.25B (2018) ⇒ $7.7B (2021) and $14.93B (2023) ○ What if you go viral? Autoscaling: your new best friend ○ What if you don't? Code not running? You're not paying. * in USD; source:Forbes (May 2018), MarketsandMarkets™ & CB Insights (Aug 2018) Serverless with Google Operational Model Programming Model Low infra management Managed security Pay only for usage Service-based monoliths Request + event-driven Open
  • 4. Google Compute Engine, Google Cloud Storage AWS EC2 & S3; Rackspace; Joyent SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda Google BigQuery, Cloud SQL, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Serverless: PaaS-y compute/processing Google Apps Script Salesforce1/force.com cloud.google.com/hosting-options#hosting-options Google Cloud compute option spectrum Compute Engine Kubernetes Engine (GKE) Cloud Run on Anthos Cloud Run (fully-mgd) App Engine (Flexible) App Engine (Standard) Cloud Functions
  • 5. Serverless common use cases App Engine Cloud Run Cloud Functions Web services Web app hosting/custom domains ✓ ✓ HTTP services ✓ ✓ ✓ Container hosting ✓ APIs Web & mobile backends ✓ ✓ Internal APIs and services ✓ ✓ Data processing ✓ ✓ Automation Workflow & orchestration ✓ ✓ Event-driven automation ✓ ✓ Common use cases 02 Google Cloud serverless ...compute platforms review
  • 6. Google App Engine App-hosting in the cloud Why does App Engine exist? ● Focus on app not DevOps ○ Web app ○ Mobile backend ○ Cloud service ● Enhance productivity ● Deploy globally ● Fully-managed ● Auto-scaling ● Pay-per-use ● Familiar languages ● Test w/local dev server
  • 7. App Engine to the rescue!! ● Focus on app not DevOps ● Enhance productivity ● Deploy globally ● Fully-managed ● Auto-scaling ● Pay-per-use ● Familiar standard runtimes ● 2nd gen std platforms ○ Python 3.7 ○ Java 8, 11 ○ PHP 7.2 ○ Go 1.11 ○ JS/Node.js 8, 10 ○ Ruby 2.5 Hello World (Python "MVP") app.yaml runtime: python38 main.py from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello World!' requirements.txt Flask==1.1.2 Deploy: $ gcloud app deploy Access globally: PROJECT_ID.appspot.com cloud.google.com/appengine/docs/standard/python3/quickstart
  • 8. Google Cloud Functions Function-hosting in the cloud Why does Cloud Functions exist? ● Don't have entire app? ○ No framework "overhead" (LAMP, MEAN...) ○ Deploy microservices ● Event-driven ○ Triggered via HTTP or background events ■ Pub/Sub, Cloud Storage, Firebase, etc. ○ Auto-scaling & highly-available; pay per use ● Flexible development environment ○ Cmd-line or developer console (in-browser) ○ Develop/test locally with Functions Framework ● Cloud Functions for Firebase ○ Mobile app use-cases ● Available runtimes ○ JS/Node.js 8, 10, 12, 14 ○ Python 3.7, 3.8, 3.9 ○ Go 1.11, 1.13 ○ Java 11 ○ Ruby 2.6, 2.7 ○ .NET Core 3.1
  • 9. main.py def hello_world(request): return 'Hello World!' Deploy: $ gcloud functions deploy hello --runtime python38 --trigger-http Access globally (curl): $ curl REGION-PROJECT_ID.cloudfunctions.net/hello Access globally (browser): https://REGION-PROJECT_ID.cloudfunctions.net/hello Hello World (Python "MVP") cloud.google.com/functions/docs/quickstart-python
  • 10. Google Cloud Run Container-hosting in the cloud The rise of containers... ● Any language ● Any library ● Any binary ● Ecosystem of base images ● Industry standard FLEXIBILITY
  • 11. “We can’t be locked in.” “How can we use existing binaries?” “Why do I have to choose between containers and serverless?” “Can you support language _______ ?” Serverless inaccessible for some... CONVENIENCE Cloud Run: code, build, deploy .js .rb .go .sh .py ... ● Any language, library, binary ○ HTTP port, stateless ● Bundle into container ○ Build w/Docker OR ○ Google Cloud Build ○ Image ⇒ Container Registry ● Deploy to Cloud Run (managed or GKE) ● GitOps: (CI/)CD Push-to-deploy from Git State HTTP
  • 12. Hello World (Python "MVP") main.py import os from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080))) cloud.google.com/run/docs/quickstarts/build-and-deploy requirements.txt Flask==1.1.2 Hello World (Python "MVP") Dockerfile FROM python:3-slim WORKDIR /app COPY . . RUN pip install -r requirements.txt CMD ["python", "main.py"] .dockerignore Dockerfile README.md *.pyc *.pyo .git/ __pycache__ Build (think docker build and docker push) then deploy (think docker run): $ gcloud builds submit --tag gcr.io/PROJ_ID/IMG_NAME $ gcloud run deploy SVC_NAME --image gcr.io/PROJ_ID/IMG_NAME OR… Build and Deploy (1-line combo of above commands): $ gcloud run deploy SVC_NAME --source . Access globally: SVC_NAME-HASH-REG_ABBR.a.run.app Docker & Dockerfile OPTIONAL!!
  • 13. ● Build containers easily & securely without creating/managing Dockerfiles ● Open source, open standard; based on CNCF Buildpacks spec v3 ● Used by GCF Functions Framework to deploy locally-developed functions ● Supports most common development tools ○ Go 1.10+ ○ Node.js 10+ ○ Python 3.7+ ○ Java 8 & 11 ○ .NET Core 3.1+ ● Blog posts ○ cloud.google.com/blog/products/containers-kubernetes/google-cloud-now-supports-buildpacks and cloud.google.com/blog/products/serverless/build-and-deploy-an-app-to-cloud-run-with-a-single-command Deploy to Cloud Run with Buildpacks github.com/GoogleCloudPlatform/buildpacks $ ls index.js package.json $ gcloud run deploy myapp --source . $ ls app.py requirements.txt $ gcloud run deploy myapp --source . 03 Nebulous, flexible app(s) Deployable to all platforms
  • 14. Flexibility in options Cloud Functions App Engine Cloud Run local server Cloud Translation My "Google Translate" MVP github.com/googlecodelabs/cloud -nebulous-serverless-python ● "Nebulous" sample web app ○ Flask/Python app ○ Python 2 & 3 compatible ○ Uses Cloud Translation API ● Deployable to on-prem server ● Also GCP serverless compute ○ App Engine ○ Cloud Functions ○ Cloud Run ● With only config changes ● No changes to app code Nebulous files ● Application files ● Configuration files ● Administrative files ○ Information files ○ Testing - CI/CD files ● Files differ per deployment ● Mainly in configuration ● Application files identical ● Administrative files not part of deployments*
  • 15. Different nebulous deployments 1. Local (or hosted) Flask server (Python 2) 2. Local (or hosted) Flask server (Python 3) 3. Google App Engine (Python 2) 4. Google App Engine (Python 3) 5. Google Cloud Functions (Python 3) 6. Google Cloud Run (Python 2 via Docker) 7. Google Cloud Run (Python 3 via Docker) 8. Google Cloud Run (Python 3 via Cloud Buildpacks) 04 Deployments & required configuration tweaks
  • 16. Local (Flask) ● Python 2 or 3 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt (install locally; see below) ○ Service acct pub/prv key-pair & download (credentials.json) ○ Point $GOOGLE_APPLICATION_CREDENTIALS env var to ^^^^ ● Run pip install -U pip -r requirements.txt ● Run python main.py Google App Engine ● Python 2 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt (install locally; see below) ○ app.yaml ○ appengine_config.py ● Run pip install -t lib -r requirements.txt ● Run gcloud app deploy
  • 17. Google App Engine ● Python 3 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt ○ app.yaml (uncomment runtime: python38) ● Run gcloud app deploy Google Cloud Functions ● Python 3 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt ● Run gcloud functions deploy translate --runtime python37 --trigger-http --allow-unauthenticated
  • 18. Google Cloud Run (Docker) ● Python 2 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt (uncomment gunicorn) ○ Dockerfile (replace ENTRYPOINT with gunicorn) ● Run gcloud beta run deploy translate --allow-unauthenticated --platform managed --source . Google Cloud Run (Docker) ● Python 3 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt (uncomment gunicorn) ○ Dockerfile (use Py3 base image & gunicorn ENTRYPOINT) ● Run gcloud beta run deploy translate --allow-unauthenticated --platform managed --source .
  • 19. Google Cloud Run (Cloud Buildpacks) ● Python 3 ● Application files ○ main.py and templates/index.html ● Config files ○ requirements.txt (uncomment gunicorn) ○ Procfile (replace web: with gunicorn) ● Run gcloud beta run deploy translate --allow-unauthenticated --platform managed --source . 05 Summary Resources & conclusion
  • 20. Possible courses for this sample app ● Software Engineering ● Intro to Cloud Computing ● Machine Learning/AI ● Web application development ● Mobile app (backends) ○ Suggest Cloud Functions for Firebase (vs. GCF) ● Data science/big data ● Business applications Cost of Google Cloud serverless tools ● What is free in Google Cloud overall? ○ Free Trial (credit card required; expires) ■ $300USD credit good for first 90 days ○ Always Free tier (credit card required; no expiration; subject to change) ■ Independent of Free Trial & education grants (more below) ■ Some GCP products free up to usage limits ○ Learn about both programs at cloud.google.com/free ● Serverless Always Free tier (monthly) ○ App Engine (28 [or 9] hours, 1GB storage & 1GB egress) per day ○ Cloud Run (2M reqs, 350k GB-secs, 180k vCPU-secs, 1GB egress) per month ○ Cloud Functions (2M calls, 400k GB-secs, 200k vCPU-secs, 5GB egress) per month ● Higher education (teaching & research) grants ○ cloud.google.com/edu (credit card NOT required; expires) ○ Provides "free" usage for coursework and initial research $$ FREE $$
  • 21. Session summary ● What's the right tool for the job? ○ GAE, GCF, GCR: they've got different use cases ○ Goal: gain familiarity with all three (learn their differences) ○ They're not as different as you may think! ● One nebulous, flexible sample web app ○ Mini "My Google Translate MVP" featuring Cloud Translation API ○ Deployable to all serverless compute platforms ○ Only requires configuration changes ○ KISS: use default service account credentials ○ github.com/googlecodelabs/cloud-nebulous-serverless-python Other Google APIs & platforms ● Google Workspace (G Suite) (code Gmail, Drive, Docs, Sheets, Slides!) ○ developers.google.com/gsuite ● Firebase (mobile development platform and RT DB plus ML-Kit) ○ firebase.google.com and firebase.google.com/docs/ml-kit ● Google Data Studio (data visualization, dashboards, etc.) ○ datastudio.google.com/overview ○ goo.gle/datastudio-course ● Actions on Google/Assistant/DialogFlow (voice apps) ○ developers.google.com/actions ● YouTube (Data, Analytics, and Livestreaming APIs) ○ developers.google.com/youtube ● Google Maps (Maps, Routes, and Places APIs) ○ developers.google.com/maps ● Flutter (native apps [Android, iOS, web] w/1 code base[!]) ○ flutter.dev
  • 22. Invite me (or my team) to your campus... it's our job! ● Faculty & grad students ● Researchers ● Undergrads ● University IT staff/CIO/CTO ● University entrepreneurship centers/capstone project leads Thank you! Questions? Wesley Chun @wescpy Progress bars: goo.gl/69EJVw