This document discusses serverless computing options on Google Cloud Platform. It begins by defining serverless and stateless applications. It then compares Cloud Functions, App Engine, and Cloud Run, explaining their key differences like runtimes, scaling, and timeouts. Cloud Functions are single-purpose and mapped to events, while App Engine can deploy full apps and services. Cloud Run runs containerized apps. The document suggests choosing based on needs like languages, websockets, and custom domains. It demonstrates using services together like functions triggering App Engine. In the end, it emphasizes the ability to mix and match serverless options.
3. Serverless Definitions
Serverless:
• Focus on code
• Don't worry about infrastructure
• Auto-scaling (+ scaling to 0)
• Pay what you use
Stateless:
• Doesn't store data
• Doesn't store application state
• No persistent storage
3@gabidavila
6. "It works on my machine"
- Every technical practitioner ever
@gabidavila
7. The "good" old days
• Named servers:
• Zeus, Thor, Odin, you get the gist!
• Certificate/user management by a SysAdmin
• FTP or SCP:
• Try uploading Magento via FTP...
• SVN or CVS to deploy code (if even!)
• Almost zero automation
7@gabidavila
8. The "modern" approach
• Machines are a commodity
• CI/CD
• Automation: Chef, Terraform, Puppet...
• Easier to scale horizontally
• Don't forget the keywords of the moment:
• Containers, Kubernetes
8@gabidavila
17. 17
Cloud Functions
def classify(request):
request_json = request.get_json()
if request.args and 'message' in request.args:
tweet = get_tweet(request.args.get('message'))
elif request_json and 'message' in request_json:
tweet = get_tweet(request_json['message'])
else:
return u'Please inform a message'
sentiment = get_sentiment(tweet['text'])
return flask.jsonify(
text = tweet['text'],
screen_name = tweet['screen_name'],
sentiment = sentiment['sentiment'],
score = sentiment['score'],
magnitude = sentiment['magnitude']
)
18. App Engine Standard
18
• Deploy an App
• Choose between 6 popular platforms
• Scale from 0 to "planet scale"
• Fully managed
App Engine
@gabidavila
19. Services and Versions
• Create services inside of the same App Engine project
• Create different versions (and serve them!) through different services
• Use cases:
• Do A/B testing
• Create dev, test, staging and prod environments!
19
App Engine Standard
@gabidavila
20. 20
App Engine Standard
Service - dev Service - prod
App Engine
Version A
InactiveInactive
Version B
Inactive
Inactive
Version C
Active
@gabidavila
Receives traffic
Version A
Active
Version B
Active
23. 23
App Engine Standard
class App < Sinatra::Base
before do
content_type 'application/json'
end
get '/status/:id' do
twitter_client = Tweets.new
language_client = GLanguage.new
tweet_status = twitter_client.status(params[:id])
response = language_client.sentiments(tweet_status[:full_text])
response[:version] = 'v1.1'
response.to_json
end
end
26. Cloud Run (beta)
26
• Fully Managed or on Anthos
• Container based
• Revision based
• Scale to zero or up and the amount of requests:
• requests = concurrency /instance * max instances
• Up to 2Gi of memory/revision
• Cloud Run on Anthos limits by your GKE cluster
Cloud Run
@gabidavila
35. Compare
App Engine standard
environment
Cloud
Functions
Cloud
Run (beta)1
Cloud Run for Anthos
(beta)1
Deployment artifact App Function Container Container
Scale to zero Pods2
Free tier
Websockets
Languages
Java, Node.js, Python,
Go, PHP, Ruby, .NET
Node.js, Python, Go Any Any
HTTP/2 and gRPC
Custom domain
Request timeout 1 minute3 9 minutes 15 minutes 15 minutes
GPUs and TPUs 35
36. Concurrency Requests
• 1 request/instance:
• Cloud Functions
• Multiple requests/instance
• App Engine standard
• Cloud Run
• Cloud Run for Anthos
36@gabidavila