Serverless, shorthand for "opinionated logic-hosting containers," continues on its sky-high trajectory. New features and products are continually being produced by vendors, all with developer focus and DevOps convenience in mind. Google has been in the serverless business long before the term even existed. In this high-level overview, we'll take you on a tour of our serverless journey, the products, use-cases, and target audiences, from the first step to the most recent, taken earlier this year at Cloud NEXT '19.
1. Google's serverless journey:
past to present
Wesley Chun
Developer Advocate, Google
Adjunct CS Faculty, Foothill College
About the speaker
Mission
● Enable current and future developers plus their technical
management everywhere to be successful using Google
Cloud and other Google developer tools & APIs.
Previous experience / background
● Software engineer & architect for 20+ years
● One of the original Yahoo!Mail engineers
● Author of bestselling "Core Python" books (corepython.com)
● Technical trainer, teacher, instructor, adjunct CS faculty
● Fellow of the Python Software Foundation
G Suite Dev Show
goo.gl/JpBQ40
2. Agenda & takeaways
1. Introduction
2. Platforms
3. Inspiration
4. Summary
● What+where
● How
● Why
● When
01
Introduction
Why are you here?
3. Serverless computing: opinionated
logic-hosting containers in the cloud
Serverless: the what
● Misnomer
● "No worries"
● According to Forbes*:
○ Developers focus on writing code &
solving business problems without
having to worry about infrastructure.
○ Servers (physical & virtual) completely
abstracted away from the user.
* source: Forbes (May 2018)
4. Serverless: the why
● Fastest growing segment of cloud
● According to pair of analyst research reports*
○ $1.9B (2016) & $4.25B (2018) ⇒ $7.7B (2021) & $14.93B (2023)
● Unless DevOps product, infrastructure less relevant for developers
● What if you go viral?
○ Autoscaling: your new best friend
● What if you don't?
○ Not running? Not incurring billing
○ Means you're not paying
○ No VMs to shutdown
○ Pay-as-you-go
* in USD; source: Research and Markets (Feb 2017) & (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
6. G Suite APIs
Top-level documentation and comprehensive developers
overview video at developers.google.com/gsuite
Google knows serverless
7. 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
G Suite (Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite
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, App Maker
Salesforce1/force.com
02
Platforms
GCP + G Suite
8. 2008 2009 2016 2019 ???
serverless timeline
Google
App Engine
(2008; 2011)
Google
Cloud Functions
(2016; 2017; 2018)
Google
Apps Script
(2009; 2009)
Google
App Maker
(2016; 2018)
Google
Cloud Run
(2019; TBD)
Building a traditional web application
Hardware failure? Traffic spikes? Scaling? Patches &
upgrades? Network issues? License management?
10. 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
Not all apps user-facing or web-based!!
● Need backend processing? Want to build your own?
● No UI required... just need HTTP
● Optimal for user info (high scores, contacts, levels/badges, etc.)
● Better UI: move user data off phone so it's universally available
11. App Engine as mobile backend
● Pulse news mobile app
○ Built in 6 short weeks by founders (2010)
○ Use of App Engine cost-effective
○ 30MM+ users, 10MM+ stories read/day
○ Thousands of QPS, 100M daily requests
● Awards
○ Apple’s App Store Hall of Fame
○ Time Magazine’s Top 50 iOS apps
● Acquired & integrated into LinkedIn (2015)
● More on Pulse
○ blog.linkedin.com/2015/06/17/introducing-the-new-linkedin-
pulse-your-daily-news-powered-by-your-professional-world
○ googleappengine.blogspot.com/2011/11/scaling-with-kindle-fire.html
○ cloud.google.com/files/Pulse.pdf
Gaming & scaling
12. Popular App Engine Use Cases
● Mobile/Tablet
○ App backends
○ Cloud persistence
● Social/Mobile Games
○ Speed, scale
○ API integrations
○ Personals/dating
● Consumer Web Apps
○ Unpredictable traffic
○ Scale (up or down)
● Apps in Academia
○ Any course where students
build web or mobile apps
○ Research projects
○ IT/Operational apps
● Business Apps
○ Enterprise
○ Java runtime
○ IT/Operational apps
○ Web or Mobile
Hello World (3 files: Python "MVP")
app.yaml
runtime: python37
main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
requirements.txt
Flask==1.0.2
Open source repo at
github.com/GoogleCloudPlatform/python-docs-samples/
tree/master/appengine/standard_python37/hello_world
13. How to deploy and where to run it
$ gcloud app deploy
● Browser
● cURL
● Mobile apps (backend, no UI needed!)
● etc.
Access globally at:
https://PROJECT_ID.appspot.com
App Engine demo
Python Flask QuickStart tutorial
(also Java, Node.js, PHP, Go, Ruby)
14. 2008 2009 2016 2019 ???
serverless timeline
Google
App Engine
(2008; 2011)
Google
Cloud Functions
(2016; 2017; 2018)
Google
Apps Script
(2009; 2009)
Google
App Maker
(2016; 2018)
Google
Cloud Run
(2019; TBD)
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
○ Node.js/JavaScript, Python, Go, Java
○ Deploy from cmd-line or developer console
● Cloud Functions for Firebase
○ Mobile app use-cases
15. Create, Deploy, Trigger
Deploying
● Create locally then deploy on cmd-line OR
● Edit and deploy from developer web console
Triggering (in response to events)
● HTTP — via HTTP request
● Cloud Storage — bucket object/metadata CRUD
● Cloud Pub/Sub — new message
● Firebase (DB, Storage, Analytics, Auth)
Available runtimes
● Node.js 6, 8, 10 (JS)
● Python 3.7
● Go 1.11, 1.12
● Java 8
BOLD == preview release
16. To create a function
Create function code locally then deploy on cmd-line
OR
1. Go to developer console @ console.cloud.google.com
2. Select a project (or create new one)
3. Choose Cloud Functions, then "Create Function"
4. Select name, memory, trigger type, language, etc.
5. Write code in browser then click to deploy (and test)
Events and triggers
Events trigger cloud functions to execute. A trigger is the type of event
that's recognized for any specific function. Functions can only be bound to
1 trigger type at a time.
EVENTS (i.e., functions are invoked when…)
1. HTTP — via HTTP request
2. Cloud Storage — bucket object/metadata CRUD
3. Cloud Pub/Sub — new message
4. Firebase (DB, Storage, Analytics, Auth)
5. Direct — CLI or developer console requests
6. others
18. No cmd-line
access?
Use in-browser
dev environment!
● setup
● code
● deploy
● test
Google Cloud Functions pricing
Resource/unit Cost
0-2 million calls FREE
2+ million calls $0.0000004/ea (40¢ per million)
GB-Second* $0.0000025
GHz-Second* $0.0000100
Outbound data $0.12/GB (5 GB/mo. free)
Inbound data, outbound data
to Google in same region
FREE
*GB-second == 1 second of wallclock time w/1GB of memory provisioned
GHz-second == 1 second of wallclock time with a 1GHz CPU provisioned
19. Cloud Functions demo
Python GCF QuickStart tutorial
(also in Node.js & Go)
2008 2009 2016 2019 ???
serverless timeline
Google
App Engine
(2008; 2011)
Google
Cloud Functions
(2016; 2017; 2018)
Google
Apps Script
(2009; 2009)
Google
App Maker
(2016; 2018)
Google
Cloud Run
(2019; TBD)
25. Creating my own ("custom") function!
Bitcoin sample
bit.ly/2kMbH1C
Woo-hoo… using my own function!
26. What can you do with this?
Accessing maps from
spreadsheets?!?
goo.gl/oAzBN9
This… with help from Google Maps & Gmail
function sendMap() {
var sheet = SpreadsheetApp.getActiveSheet();
var address = sheet.getRange("A2").getValue();
var map = Maps.newStaticMap().addMarker(address);
GmailApp.sendEmail('friend@example.com', 'Map',
'See below.', {attachments:[map]});
}
JS
27. ● Extend functionality of G Suite editors
● Embed your app within ours!
● 2014: Google Docs, Sheets, Forms
● 2017 Q3: Google Slides
● 2017 Q4: Gmail
● 2018 Q1: Hangouts Chat bots
● Apps Script also powers App Maker,
Google Data Studio community
connectors, and Google Ads scripts
Apps Script powers add-ons… and more!
28. Making progress (bars) with Slides Add-ons
var BAR_ID = 'PROGRESS_BAR_ID';
var BAR_HEIGHT = 10; // px
var presentation = SlidesApp.getActivePresentation();
function createBars() {
var slides = presentation.getSlides();
deleteBars();
for (var i = 0; i < slides.length; ++i) {
var ratioComplete = (i / (slides.length - 1));
var x = 0;
var y = presentation.getPageHeight() - BAR_HEIGHT;
var barWidth = presentation.getPageWidth() * ratioComplete;
if (barWidth > 0) {
var bar = slides[i].insertShape(SlidesApp.ShapeType.RECTANGLE,
x, y, barWidth, BAR_HEIGHT);
bar.getBorder().setTransparent();
bar.setLinkUrl(BAR_ID);
}
}
}
Progress bars
goo.gl/69EJVw
Making progress (bars) with Slides Add-ons
29. Expense
reports...
● Expense reports
● Can't we do them
without leaving Gmail?
● On Web AND mobile?
● At your desk or on the road
● One place to complete
your expense report
● One code base
Gmail Add-ons
Expediting expense
reports
goo.gl/KUVCDu
30. ● Not just for conversations
● Create microservice utilities
● Build chat bots to...
○ Automate workflows
○ Query for information
○ Other heavy-lifting
Hangouts Chat bots
(bot framework and API)
function onMessage(e) {
return createMessage(e.user.displayName, 0);
}
function onCardClick(e) {
// Create a new vote card when 'NEW' button is clicked.
if (e.action.actionMethodName === 'newvote') {
return createMessage(e.user.displayName, 0);
}
// Updates the card in-place when '+1' or '-1' button is clicked.
var voteCount = +e.action.parameters[0].value;
e.action.actionMethodName === 'upvote' ? ++voteCount : --voteCount;
return createMessage(e.user.displayName, voteCount, true);
}
Simple vote bot
32. ● Command-line interface
● Intergrate with git plus
your local IDE/dev env.
● Actions
○ Create
○ Pull
○ Push
○ Clone
○ Deploy
○ View logs
● Built on Apps Script API
● Launched early 2018
Professional workflow with clasp tool
2008 2009 2016 2019 ???
serverless timeline
Google
App Engine
(2008; 2011)
Google
Cloud Functions
(2016; 2017; 2018)
Google
Apps Script
(2009; 2009)
Google
App Maker
(2016; 2018)
Google
Cloud Run
(2019; TBD)
33. Got app licenses for sales,
marketing & operations?
BUT...
Who builds my app?
If no resources, how
do I do it myself?
Custom business apps: still no easy solutions
Who will pay
for it?
What platform
should I use?
Where do I host
my data?
Is my app
compliant?
Who has access
to my app?
34. ● Low-code assistive development
environment; Cloud SQL default
● Go from idea to app in minutes
● Drag-n-drop app building
● Many pre-made template apps
● Generates Apps Script code
● Requires at least G Suite Business
Google App Maker
Operational / Process
Employee directory
Room scheduling
Budget tracking
Project & task tracking
Meeting planning
Security dashboard
Travel approvals
Line of Business (LOB)
Lender limits
Inventory management
Content management
Legal contracts
Student progress
Custom apps across use-cases
35. 2008 2009 2016 2019 ???
serverless timeline
Google
App Engine
(2008; 2011)
Google
Cloud Functions
(2016; 2017; 2018)
Google
Apps Script
(2009; 2009)
Google
App Maker
(2016; 2018)
Google
Cloud Run
(2019; TBD)
The rise of containers ● Any language
● Any library
● Any binary
● Ecosystem of base images
● Industry standard
36. “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 not accessible to everyone...
● Fully-managed serverless "CaaS"
○ Flexibility and portability of containers, but
with the convenience of serverless
○ You app, your bundled container
○ Auto-scale, -provision, -config
○ Pay-per-use
● Anti-vendor lock-in, portable to:
○ Google-managed Kubernetes cluster (GKE)
○ Or your self-managed Kubernetes cluster
Google Cloud Run to the rescue!
37. 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)
StateHTTP
https://yourservice.run.app
Hello World (3 files: Python "MVP")
Dockerfile
FROM python:3.7
ENV APP_HOME /app
ENV TARGET MHacks2019
WORKDIR $APP_HOME
COPY . .
RUN pip install Flask gunicorn
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 app:app
cloud.google.com/run/docs/quickstarts/build-and-deploy or
github.com/knative/docs/tree/master/docs/serving/samples/h
ello-world/helloworld-python
.dockerignore
Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
46. Supercharge G Suite with GCP
G Suite GCP
BigQuery
Apps Script
Slides Sheets
Application
request
Big data
analytics
47. Hangouts Chat Productivity Tracker
Chat bot that's GCP & G Suite aware
Productivity tracker Hangouts Chat bot
G Suite GCP
Sheets Natural Language
START
or LOG
END
Hangouts
Chat
App
Engine
Cloud
SQL
48. App summary
● Motivation
● Do coding contract jobs during school year
● Needed to track time spent on work (and non-work)
● Who doesn't want to be more productive?
● Hangouts Chat bot framework & API... build bots to:
● Automate workflows
● Query for information
● Other heavy-lifting
● G Suite app that leverages app-hosting, NL processing, and storage tools from GCP
● Application source code
● github.com/gsuitedevs/hangouts-chat-samples/tree/master/python/productivity_tracker
● Presented at GDG Silicon Valley (Aug 2018)
● meetup.com/gdg-silicon-valley/events/252858660
49. 04
What's Next?
Summary
● Serverless: organizations can focus on solving problems, not infrastructure
● Managed app-/service-hosting, or container-hosting for ultimate flexibility
● Google knows serverless
○ Over a decade of experience: been doing it before term existed
○ Variety of products serving different business needs
○ cloud.google.com/serverless and developers.google.com/gsuite
● Products
○ 2008: cloud.google.com/appengine
○ 2009: developers.google.com/apps-script
○ 2016: cloud.google.com/functions
○ 2016: gsuite.google.com/appmaker
○ 2019: cloud.google.com/run
Know AWS? Compare with GCP here:
cloud.google.com/docs/compare/aws