SlideShare a Scribd company logo
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Boaz Ziniman - Technical Evangelist
Amazon Web Service
Serverless Beyond Functions
@ziniman
boaz.ziniman.aws
ziniman
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless applications
Services (anything)
Changes in
data state
Requests to
endpoints
Changes in
resource state
Event source Function
Node.js
Python
Java
C# / F# / PowerShell
Go
Ruby
Runtime API
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Anatomy of a Lambda function
Handler() function
Function to be executed
upon invocation
Event object
Data sent during Lambda
function Invocation
Context object
Methods available to
interact with runtime
information (request ID,
log group, more)
import json
def lambda_handler(event, context):
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello World!')
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“I know how to build a serverless
function, now what?”
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
• Orchestration
• CI/CD
• Step Functions
• Layers
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Project Orchestration
© 2019, Amazon Web Services, Inc. or its Affiliates.
Start with a framework
AWS
Chalice
AWS Amplify
AWS
SAM
AWS: Third-party:
Serverless
Framework
Meet
SAM!
© 2019, Amazon Web Services, Inc. or its Affiliates.
AWS Serverless Application Model (SAM)
AWS CloudFormation extension optimized for
serverless
Special serverless resource types: Functions, APIs,
SimpleTables, Layers, and Applications
Supports anything AWS CloudFormation supports
Open specification (Apache 2.0)
https://aws.amazon.com/serverless/sam
© 2019, Amazon Web Services, Inc. or its Affiliates.
AWS Serverless Application Model (SAM)
AWSTemplateFormatVersion: '2010-09-09’
Transform: AWS::Serverless-2016-10-31
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs8.10
CodeUri: src/
Policies:
- DynamoDBReadPolicy:
TableName: !Ref MyTable
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
MyTable:
Type: AWS::Serverless::SimpleTable
Just 20 lines to create:
• Lambda function
• IAM role
• API Gateway
• DynamoDB table
O
pen
Source
© 2019, Amazon Web Services, Inc. or its Affiliates.
Use SAM CLI to package and deploy SAM templates
pip install --user aws-sam-cli
sam init --name my-app --runtime python
cd my-app/
sam local ... # generate-event/invoke/start-api/start-lambda
sam validate # The SAM template
sam build # Depending on the runtime
sam package --s3-bucket my-packages-bucket 
--output-template-file packaged.yaml
sam deploy --template-file packaged.yaml 
--stack-name my-stack-prod
sam logs -n MyFunction --stack-name my-stack-prod -t # Tail
sam publish # To the Serverless Application Repository
O
pen
Source
CodePipeline
Use
CloudFormation
deployment actions
with any SAM
application
Jenkins
Use SAM CLI plugin
© 2019, Amazon Web Services, Inc. or its Affiliates.© 2019, Amazon Web Services, Inc. or its Affiliates.
© 2019, Amazon Web Services, Inc. or its Affiliates.
With the AWS Serverless Application Repository:
Developers can…
• Discover and deploy ready-made apps and
code samples
• Combine applications in the app repository
with their own via Nested Applications
• Customize open-source apps to get started
quickly
• Share apps privately or publish apps
for public use
© 2019, Amazon Web Services, Inc. or its Affiliates.
TweetSource:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:...
SemanticVersion: 2.0.0
Parameters:
TweetProcessorFunctionName: !Ref MyFunction
SearchText: '#serverless -filter:nativeretweets'
Nested apps to simplify solving recurring problems
Standard
Component
Custom
Business
Logic
Polling schedule
(CloudWatch
Events rule)
trigger
TwitterProcessor
SearchCheckpoint
TwitterSearchPoller
Twitter
Search API
© 2019, Amazon Web Services, Inc. or its Affiliates.
AWS Lambda Environment Variables
• Key-value pairs that you can dynamically pass to your
function
• Available via standard environment variable APIs such
as process.env for Node.js or os.environ for Python
• Can optionally be encrypted via AWS Key
Management Service (KMS)
• Allows you to specify in IAM what roles have access to the
keys to decrypt the information
• Useful for creating environments per stage
(i.e. dev, testing, production)
© 2019, Amazon Web Services, Inc. or its Affiliates.
Amazon API Gateway Stage Variables
Stage variables act like environment variables
• Use stage variables to store configuration values
• Stage variables are available in the $context object
• Values are accessible from most fields
in API Gateway
• Lambda function ARN
• HTTP endpoint
• Custom authorizer function name
• Parameter mappings
Amazon API
Gateway
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CI/CD for Serverless
© 2019, Amazon Web Services, Inc. or its Affiliates.
Source Build Test Production
Continuous Integration / Continuous Deployment
© 2019, Amazon Web Services, Inc. or its Affiliates.
Serverless deployments
Code
StackPackage Deploy
Template
© 2019, Amazon Web Services, Inc. or its Affiliates.
Serverless deployments with a test environment
Code
Test
Stack
Package Deploy
Template
Feedback
Production
Stack
Deploy
© 2019, Amazon Web Services, Inc. or its Affiliates.
MyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs6.10
AutoPublishAlias: !Ref ENVIRONMENT
DeploymentPreference:
Type: Linear10PercentEvery10Minutes
Alarms:
# A list of alarms that you want to monitor
- !Ref AliasErrorMetricGreaterThanZeroAlarm
- !Ref LatestVersionErrorMetricGreaterThanZeroAlarm
Hooks:
# Validation Lambda functions that are run before & after traffic shifting
PreTraffic: !Ref PreTrafficLambdaFunction
PostTraffic: !Ref PostTrafficLambdaFunction
AWS SAM + Safe Deployments
© 2019, Amazon Web Services, Inc. or its Affiliates.
CodeDeploy – Lambda deployments in SAM templates
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
AutoPublishAlias: live
DeploymentPreference:
Type: Canary10Percent10Minutes
Alarms:
- !Ref ErrorsAlarm
- !Ref LatencyAlarm
Hooks:
PreTraffic: !Ref PreTrafficHookFunction
PostTraffic: !Ref PostTrafficHookFunction
Canary10Percent30Minutes
Canary10Percent5Minutes
Canary10Percent10Minutes
Canary10Percent15Minutes
Linear10PercentEvery10Minutes
Linear10PercentEvery1Minute
Linear10PercentEvery2Minutes
Linear10PercentEvery3Minutes
AllAtOnce
© 2019, Amazon Web Services, Inc. or its Affiliates.
Alarms: # A list of alarms that you want to monitor
- !Ref AliasErrorMetricGreaterThanZeroAlarm
- !Ref LatestVersionErrorMetricGreaterThanZeroAlarm
Hooks: # Validation Lambda functions that are run before & after
traffic shifting
PreTraffic: !Ref PreTrafficLambdaFunction
PostTraffic: !Ref PostTrafficLambdaFunction
AWS Lambda Alias Traffic Shifting & AWS SAM
Note: You can specify a maximum of 10
alarms
In SAM:
© 2019, Amazon Web Services, Inc. or its Affiliates.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias
“live”
v1
Lambda
function
code
100%
© 2019, Amazon Web Services, Inc. or its Affiliates.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias
“live”
v1 code100%
Run PreTraffic hook against v2 code before it receives traffic
v2 code0%
© 2019, Amazon Web Services, Inc. or its Affiliates.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias
“live”
v1 code90%
Wait for 10 minutes, roll back in case of alarm
v2 code10%
© 2019, Amazon Web Services, Inc. or its Affiliates.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias
“live”
v1 code0%
Run PostTraffic hook and complete deployment
v2 code100%
© 2019, Amazon Web Services, Inc. or its Affiliates.
API Gateway canary stage
API
Gateway
Production
stage
v1 code
v2 code
99.5%
0.5% Canary
stage
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo
https://github.com/ziniman/aws-devday-storereply
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Step Functions
Application Lifecycle in AWS Step Functions
Visualize in the
Console
Define in JSON Monitor
Executions
Define in JSON and Then Visualize in the Console
{
"Comment": "Hello World Example",
"StartAt" : "HelloWorld",
"States" : {
"HelloWorld" : {
"Type" : "Task",
"Resource" : "${lambdaArn}",
"End" : true
}
}
}
Execute One or One Million
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Maximum Execution Time
AWS Lambda
Functions
15 minutes
AWS Step Functions
State Machines
1 year
Monitor Executions from the Console
Seven State Types
Task A single unit of work
Choice Adds branching logic
Parallel Fork and join the data across tasks
Wait Delay for a specified time
Fail Stops an execution and marks it as a failure
Succeed Stops an execution successfully
Pass Passes its input to its output
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Step Functions Tasks – Service Integrations
AWS Lambda invoke a Lambda function
AWS Batch submit a Batch job and wait for it to complete
Amazon DynamoDB get, put, update or delete an item
Amazon ECS/Fargate run an ECS task and waits for it to complete
Amazon SNS publish a message to a SNS topic
Amazon SQS send a SQS message
AWS Glue start a Glue job
Amazon SageMaker create a training or transform job
Build Visual Workflows from State Types
Task
Choice
Fail
Parallel
Image Recognition and Processing Backend
Task
Choice
Fail
Parallel
https://github.com/awslabs/lambda-refarch-imagerecognition
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Step Functions Demo
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Step Functions Case Studies
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Vending Pass problem
1. Thirsty consumer presents
card, can buy a drink with
Vending Pass or debit
2. But mobile wallet display can
get out of sync under certain
conditions
3.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Vending Pass problem
• Just wait for backend
to catch up
• Create a two-step state
machine:
• Wait (90 seconds)
• Update mobile wallet
• Cheap and simple!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Transcode 350 clips/day into
14 formats, fast
• It’s all done with FFmpeg. The
processing time is just about
100% of the video length
• Aargh!
Video processing problem
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Derive keyframe locations
within the source
• Split the source at the
keyframes
• Process segments (typically
0.5 sec per) in parallel
• Concatenate segments
• Elapsed time: ~20 min down
to ~2 minutes
Video processing solution
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Takeaways
Use Amazon S3 data events
to trigger parallel Lambda
processing: win
Use Amazon S3
URLs to stream
video to
Lambda: win
Scaling to 1,000
Lambdas, rather
than 1,000 EC2
instances: win
Process video
segments in
parallel: win
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
More state machines
Image Recognition and Processing BackendEBS Snapshot Management
https://aws.amazon.com/step-functions/getting-started
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Layers
© 2019, Amazon Web Services, Inc. or its Affiliates.
Lambda Layers
Lets functions easily share code: Upload layer
once, reference within any function
Promote separation of responsibilities, lets
developers iterate faster on writing business logic
Built in support for secure sharing by ecosystem
© 2019, Amazon Web Services, Inc. or its Affiliates.
Using Lambda Layers
• Put common components in a ZIP file and
upload it as a Lambda Layer
• Layers are immutable and can be versioned
to manage updates
• When a version is deleted or permissions to
use it are revoked, functions that used it
previously will continue to work, but you
won’t be able to create new ones
• You can reference up to five layers, one of
which can optionally be a custom runtime
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:2
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:3
© 2019, Amazon Web Services, Inc. or its Affiliates.
Lambda Runtime API
Bring any Linux compatible language runtime
Powered by new Runtime API - Codifies the
runtime calling conventions and integration points
At launch, custom runtimes powering Ruby
support in AWS Lambda, more runtimes from
partners (like Erlang)
Custom runtimes distributed as “layers”
Rule
Stack
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
PHP Runtime Demo
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You!
Boaz Ziniman
Technical Evangelist - Amazon Web Services
@ziniman
boaz.ziniman.aws
ziniman

More Related Content

Similar to Serverless Beyond Functions - CTO Club Made in JLM (20)

PDF
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
AWS Summits
 
PDF
CI/CD for AWS Lambda Projects - IsraelCloud Meetup
Boaz Ziniman
 
PPTX
Introduction to AWS lambda & Serverless Application1.pptx
Mohammed Shefeeq
 
PDF
Serverless workshop with Amazon Web Services
TheFamily
 
PPTX
The family - presentation on AWS Serverless
Alexandre Pinhel
 
PDF
What’s new in serverless - re:Invent 2020
AWS Chicago
 
PDF
AWSomeDay Zurich 2018 - How to go serverless
Roman Plessl
 
PDF
Voxxed Athens 2018 - Serverless by Design
Voxxed Athens
 
PPTX
Getting started with Serverless on AWS
Adrian Hornsby
 
PPTX
The Future of Enterprise Applications is Serverless
Eficode
 
PDF
Getting Started with AWS Lambda and Serverless Computing
Kristana Kane
 
PPTX
Serverless in Action on AWS
Adrian Hornsby
 
PPTX
muCon 2017 - 12 Factor Serverless Applications
Chris Munns
 
PDF
Building Serverless Microservices with AWS
Donnie Prakoso
 
PDF
Serverless on AWS: Architectural Patterns and Best Practices
Vladimir Simek
 
PDF
AWS Summit Singapore 2019 | The Serverless Lifecycle: Development and Operati...
AWS Summits
 
PDF
Building serverless apps with Node.js
Julien SIMON
 
PPTX
Meet AWS SAM
Eric Johnson
 
PDF
Serverless use cases with AWS Lambda - More Serverless Event
Boaz Ziniman
 
PDF
12 Factor Serverless Applications - Mike Morain, AWS - Cloud Native Day Tel A...
Cloud Native Day Tel Aviv
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
AWS Summits
 
CI/CD for AWS Lambda Projects - IsraelCloud Meetup
Boaz Ziniman
 
Introduction to AWS lambda & Serverless Application1.pptx
Mohammed Shefeeq
 
Serverless workshop with Amazon Web Services
TheFamily
 
The family - presentation on AWS Serverless
Alexandre Pinhel
 
What’s new in serverless - re:Invent 2020
AWS Chicago
 
AWSomeDay Zurich 2018 - How to go serverless
Roman Plessl
 
Voxxed Athens 2018 - Serverless by Design
Voxxed Athens
 
Getting started with Serverless on AWS
Adrian Hornsby
 
The Future of Enterprise Applications is Serverless
Eficode
 
Getting Started with AWS Lambda and Serverless Computing
Kristana Kane
 
Serverless in Action on AWS
Adrian Hornsby
 
muCon 2017 - 12 Factor Serverless Applications
Chris Munns
 
Building Serverless Microservices with AWS
Donnie Prakoso
 
Serverless on AWS: Architectural Patterns and Best Practices
Vladimir Simek
 
AWS Summit Singapore 2019 | The Serverless Lifecycle: Development and Operati...
AWS Summits
 
Building serverless apps with Node.js
Julien SIMON
 
Meet AWS SAM
Eric Johnson
 
Serverless use cases with AWS Lambda - More Serverless Event
Boaz Ziniman
 
12 Factor Serverless Applications - Mike Morain, AWS - Cloud Native Day Tel A...
Cloud Native Day Tel Aviv
 

More from Boaz Ziniman (20)

PDF
AWS Cost Optimization - JLM
Boaz Ziniman
 
PDF
What can you do with Serverless in 2020
Boaz Ziniman
 
PDF
Six ways to reduce your AWS bill
Boaz Ziniman
 
PDF
From Cloud to Edge & back again
Boaz Ziniman
 
PDF
Modern Applications Development on AWS
Boaz Ziniman
 
PDF
Enriching your app with Image recognition and AWS AI services Hebrew Webinar
Boaz Ziniman
 
PDF
AI Services and Serverless Workshop
Boaz Ziniman
 
PDF
Drive Down the Cost of your Data Lake by Using the Right Data Tiering
Boaz Ziniman
 
PDF
Breaking Voice and Language Barriers with AI - Chatbot Summit Tel Aviv
Boaz Ziniman
 
PDF
Websites Go Serverless - ServerlessDays TLV 2019
Boaz Ziniman
 
PDF
SKL208 - Turbocharge your Business with AI and Machine Learning - Tel Aviv Su...
Boaz Ziniman
 
PDF
AIM301 - Breaking Language Barriers With AI - Tel Aviv Summit 2019
Boaz Ziniman
 
PDF
Breaking Language Barriers with AI - AWS Summit
Boaz Ziniman
 
PDF
Websites go Serverless - AWS Summit Berlin
Boaz Ziniman
 
PDF
AWS Lambda updates from re:Invent
Boaz Ziniman
 
PDF
Artificial Intelligence for Developers - OOP Munich
Boaz Ziniman
 
PDF
Introduction to Serverless Computing - OOP Munich
Boaz Ziniman
 
PDF
IoT from Cloud to Edge & Back Again - WebSummit 2018
Boaz Ziniman
 
PDF
Breaking Language Barriers with AI - Web Summit 2018
Boaz Ziniman
 
PDF
How Websites go Serverless - WebSummit Lisbon 2018
Boaz Ziniman
 
AWS Cost Optimization - JLM
Boaz Ziniman
 
What can you do with Serverless in 2020
Boaz Ziniman
 
Six ways to reduce your AWS bill
Boaz Ziniman
 
From Cloud to Edge & back again
Boaz Ziniman
 
Modern Applications Development on AWS
Boaz Ziniman
 
Enriching your app with Image recognition and AWS AI services Hebrew Webinar
Boaz Ziniman
 
AI Services and Serverless Workshop
Boaz Ziniman
 
Drive Down the Cost of your Data Lake by Using the Right Data Tiering
Boaz Ziniman
 
Breaking Voice and Language Barriers with AI - Chatbot Summit Tel Aviv
Boaz Ziniman
 
Websites Go Serverless - ServerlessDays TLV 2019
Boaz Ziniman
 
SKL208 - Turbocharge your Business with AI and Machine Learning - Tel Aviv Su...
Boaz Ziniman
 
AIM301 - Breaking Language Barriers With AI - Tel Aviv Summit 2019
Boaz Ziniman
 
Breaking Language Barriers with AI - AWS Summit
Boaz Ziniman
 
Websites go Serverless - AWS Summit Berlin
Boaz Ziniman
 
AWS Lambda updates from re:Invent
Boaz Ziniman
 
Artificial Intelligence for Developers - OOP Munich
Boaz Ziniman
 
Introduction to Serverless Computing - OOP Munich
Boaz Ziniman
 
IoT from Cloud to Edge & Back Again - WebSummit 2018
Boaz Ziniman
 
Breaking Language Barriers with AI - Web Summit 2018
Boaz Ziniman
 
How Websites go Serverless - WebSummit Lisbon 2018
Boaz Ziniman
 
Ad

Recently uploaded (20)

PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
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
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Ad

Serverless Beyond Functions - CTO Club Made in JLM

  • 1. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Boaz Ziniman - Technical Evangelist Amazon Web Service Serverless Beyond Functions @ziniman boaz.ziniman.aws ziniman
  • 2. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 3. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless applications Services (anything) Changes in data state Requests to endpoints Changes in resource state Event source Function Node.js Python Java C# / F# / PowerShell Go Ruby Runtime API
  • 4. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Anatomy of a Lambda function Handler() function Function to be executed upon invocation Event object Data sent during Lambda function Invocation Context object Methods available to interact with runtime information (request ID, log group, more) import json def lambda_handler(event, context): # TODO implement return { 'statusCode': 200, 'body': json.dumps('Hello World!') }
  • 5. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “I know how to build a serverless function, now what?”
  • 6. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda • Orchestration • CI/CD • Step Functions • Layers
  • 7. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Project Orchestration
  • 8. © 2019, Amazon Web Services, Inc. or its Affiliates. Start with a framework AWS Chalice AWS Amplify AWS SAM AWS: Third-party: Serverless Framework
  • 10. © 2019, Amazon Web Services, Inc. or its Affiliates. AWS Serverless Application Model (SAM) AWS CloudFormation extension optimized for serverless Special serverless resource types: Functions, APIs, SimpleTables, Layers, and Applications Supports anything AWS CloudFormation supports Open specification (Apache 2.0) https://aws.amazon.com/serverless/sam
  • 11. © 2019, Amazon Web Services, Inc. or its Affiliates. AWS Serverless Application Model (SAM) AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs8.10 CodeUri: src/ Policies: - DynamoDBReadPolicy: TableName: !Ref MyTable Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get MyTable: Type: AWS::Serverless::SimpleTable Just 20 lines to create: • Lambda function • IAM role • API Gateway • DynamoDB table O pen Source
  • 12. © 2019, Amazon Web Services, Inc. or its Affiliates. Use SAM CLI to package and deploy SAM templates pip install --user aws-sam-cli sam init --name my-app --runtime python cd my-app/ sam local ... # generate-event/invoke/start-api/start-lambda sam validate # The SAM template sam build # Depending on the runtime sam package --s3-bucket my-packages-bucket --output-template-file packaged.yaml sam deploy --template-file packaged.yaml --stack-name my-stack-prod sam logs -n MyFunction --stack-name my-stack-prod -t # Tail sam publish # To the Serverless Application Repository O pen Source CodePipeline Use CloudFormation deployment actions with any SAM application Jenkins Use SAM CLI plugin
  • 13. © 2019, Amazon Web Services, Inc. or its Affiliates.© 2019, Amazon Web Services, Inc. or its Affiliates.
  • 14. © 2019, Amazon Web Services, Inc. or its Affiliates. With the AWS Serverless Application Repository: Developers can… • Discover and deploy ready-made apps and code samples • Combine applications in the app repository with their own via Nested Applications • Customize open-source apps to get started quickly • Share apps privately or publish apps for public use
  • 15. © 2019, Amazon Web Services, Inc. or its Affiliates. TweetSource: Type: AWS::Serverless::Application Properties: Location: ApplicationId: arn:aws:serverlessrepo:... SemanticVersion: 2.0.0 Parameters: TweetProcessorFunctionName: !Ref MyFunction SearchText: '#serverless -filter:nativeretweets' Nested apps to simplify solving recurring problems Standard Component Custom Business Logic Polling schedule (CloudWatch Events rule) trigger TwitterProcessor SearchCheckpoint TwitterSearchPoller Twitter Search API
  • 16. © 2019, Amazon Web Services, Inc. or its Affiliates. AWS Lambda Environment Variables • Key-value pairs that you can dynamically pass to your function • Available via standard environment variable APIs such as process.env for Node.js or os.environ for Python • Can optionally be encrypted via AWS Key Management Service (KMS) • Allows you to specify in IAM what roles have access to the keys to decrypt the information • Useful for creating environments per stage (i.e. dev, testing, production)
  • 17. © 2019, Amazon Web Services, Inc. or its Affiliates. Amazon API Gateway Stage Variables Stage variables act like environment variables • Use stage variables to store configuration values • Stage variables are available in the $context object • Values are accessible from most fields in API Gateway • Lambda function ARN • HTTP endpoint • Custom authorizer function name • Parameter mappings Amazon API Gateway
  • 18. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CI/CD for Serverless
  • 19. © 2019, Amazon Web Services, Inc. or its Affiliates. Source Build Test Production Continuous Integration / Continuous Deployment
  • 20. © 2019, Amazon Web Services, Inc. or its Affiliates. Serverless deployments Code StackPackage Deploy Template
  • 21. © 2019, Amazon Web Services, Inc. or its Affiliates. Serverless deployments with a test environment Code Test Stack Package Deploy Template Feedback Production Stack Deploy
  • 22. © 2019, Amazon Web Services, Inc. or its Affiliates. MyLambdaFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: nodejs6.10 AutoPublishAlias: !Ref ENVIRONMENT DeploymentPreference: Type: Linear10PercentEvery10Minutes Alarms: # A list of alarms that you want to monitor - !Ref AliasErrorMetricGreaterThanZeroAlarm - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm Hooks: # Validation Lambda functions that are run before & after traffic shifting PreTraffic: !Ref PreTrafficLambdaFunction PostTraffic: !Ref PostTrafficLambdaFunction AWS SAM + Safe Deployments
  • 23. © 2019, Amazon Web Services, Inc. or its Affiliates. CodeDeploy – Lambda deployments in SAM templates Resources: GetFunction: Type: AWS::Serverless::Function Properties: AutoPublishAlias: live DeploymentPreference: Type: Canary10Percent10Minutes Alarms: - !Ref ErrorsAlarm - !Ref LatencyAlarm Hooks: PreTraffic: !Ref PreTrafficHookFunction PostTraffic: !Ref PostTrafficHookFunction Canary10Percent30Minutes Canary10Percent5Minutes Canary10Percent10Minutes Canary10Percent15Minutes Linear10PercentEvery10Minutes Linear10PercentEvery1Minute Linear10PercentEvery2Minutes Linear10PercentEvery3Minutes AllAtOnce
  • 24. © 2019, Amazon Web Services, Inc. or its Affiliates. Alarms: # A list of alarms that you want to monitor - !Ref AliasErrorMetricGreaterThanZeroAlarm - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm Hooks: # Validation Lambda functions that are run before & after traffic shifting PreTraffic: !Ref PreTrafficLambdaFunction PostTraffic: !Ref PostTrafficLambdaFunction AWS Lambda Alias Traffic Shifting & AWS SAM Note: You can specify a maximum of 10 alarms In SAM:
  • 25. © 2019, Amazon Web Services, Inc. or its Affiliates. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 Lambda function code 100%
  • 26. © 2019, Amazon Web Services, Inc. or its Affiliates. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 code100% Run PreTraffic hook against v2 code before it receives traffic v2 code0%
  • 27. © 2019, Amazon Web Services, Inc. or its Affiliates. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 code90% Wait for 10 minutes, roll back in case of alarm v2 code10%
  • 28. © 2019, Amazon Web Services, Inc. or its Affiliates. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 code0% Run PostTraffic hook and complete deployment v2 code100%
  • 29. © 2019, Amazon Web Services, Inc. or its Affiliates. API Gateway canary stage API Gateway Production stage v1 code v2 code 99.5% 0.5% Canary stage
  • 30. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo https://github.com/ziniman/aws-devday-storereply
  • 31. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Step Functions
  • 32. Application Lifecycle in AWS Step Functions Visualize in the Console Define in JSON Monitor Executions
  • 33. Define in JSON and Then Visualize in the Console { "Comment": "Hello World Example", "StartAt" : "HelloWorld", "States" : { "HelloWorld" : { "Type" : "Task", "Resource" : "${lambdaArn}", "End" : true } } }
  • 34. Execute One or One Million Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld
  • 35. Maximum Execution Time AWS Lambda Functions 15 minutes AWS Step Functions State Machines 1 year
  • 36. Monitor Executions from the Console
  • 37. Seven State Types Task A single unit of work Choice Adds branching logic Parallel Fork and join the data across tasks Wait Delay for a specified time Fail Stops an execution and marks it as a failure Succeed Stops an execution successfully Pass Passes its input to its output
  • 38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Step Functions Tasks – Service Integrations AWS Lambda invoke a Lambda function AWS Batch submit a Batch job and wait for it to complete Amazon DynamoDB get, put, update or delete an item Amazon ECS/Fargate run an ECS task and waits for it to complete Amazon SNS publish a message to a SNS topic Amazon SQS send a SQS message AWS Glue start a Glue job Amazon SageMaker create a training or transform job
  • 39. Build Visual Workflows from State Types Task Choice Fail Parallel
  • 40. Image Recognition and Processing Backend Task Choice Fail Parallel https://github.com/awslabs/lambda-refarch-imagerecognition
  • 41. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Step Functions Demo
  • 42. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Step Functions Case Studies
  • 43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Vending Pass problem 1. Thirsty consumer presents card, can buy a drink with Vending Pass or debit 2. But mobile wallet display can get out of sync under certain conditions 3.
  • 44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Vending Pass problem • Just wait for backend to catch up • Create a two-step state machine: • Wait (90 seconds) • Update mobile wallet • Cheap and simple!
  • 45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Transcode 350 clips/day into 14 formats, fast • It’s all done with FFmpeg. The processing time is just about 100% of the video length • Aargh! Video processing problem
  • 46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Derive keyframe locations within the source • Split the source at the keyframes • Process segments (typically 0.5 sec per) in parallel • Concatenate segments • Elapsed time: ~20 min down to ~2 minutes Video processing solution
  • 47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Takeaways Use Amazon S3 data events to trigger parallel Lambda processing: win Use Amazon S3 URLs to stream video to Lambda: win Scaling to 1,000 Lambdas, rather than 1,000 EC2 instances: win Process video segments in parallel: win
  • 48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. More state machines Image Recognition and Processing BackendEBS Snapshot Management https://aws.amazon.com/step-functions/getting-started
  • 49. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Layers
  • 50. © 2019, Amazon Web Services, Inc. or its Affiliates. Lambda Layers Lets functions easily share code: Upload layer once, reference within any function Promote separation of responsibilities, lets developers iterate faster on writing business logic Built in support for secure sharing by ecosystem
  • 51. © 2019, Amazon Web Services, Inc. or its Affiliates. Using Lambda Layers • Put common components in a ZIP file and upload it as a Lambda Layer • Layers are immutable and can be versioned to manage updates • When a version is deleted or permissions to use it are revoked, functions that used it previously will continue to work, but you won’t be able to create new ones • You can reference up to five layers, one of which can optionally be a custom runtime Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:2 Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:3
  • 52. © 2019, Amazon Web Services, Inc. or its Affiliates. Lambda Runtime API Bring any Linux compatible language runtime Powered by new Runtime API - Codifies the runtime calling conventions and integration points At launch, custom runtimes powering Ruby support in AWS Lambda, more runtimes from partners (like Erlang) Custom runtimes distributed as “layers” Rule Stack
  • 53. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. PHP Runtime Demo
  • 54. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank You! Boaz Ziniman Technical Evangelist - Amazon Web Services @ziniman boaz.ziniman.aws ziniman