Getting Started with Serverless Architectures

Amazon Web Services
Amazon Web ServicesAmazon Web Services
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Vyom Nagrani
Manager Product Management, AWS Lambda
30th March, 2016
Getting Started with
Serverless Architectures
Agenda
 Background
 AWS Lambda
 Amazon API Gateway
 Serverless Architecture Patterns
 Serverless Best Practices
Background
How serverless architecture patterns with AWS Lambda are the next
evolution of application design
The Monolithic Application
The Monolithic Application
• Lots of Collateral Damage
• All-for-one and one-to-fail
• Slipped timelines
• Operational issues
• Deploy Less Frequently
• Less disruption
• More time to plan
Reduce
Risk
Break it apart.
The Monolithic Architecture
The Service Oriented Architecture
Presentation Tier
Logic Tier
Data Tier
The Microservices Architecture
Tools to help this pattern are VAST
 Web Servers
 Code Libraries
 Web Service/Application Frameworks
 Configuration Management Tools
 API Management Platforms
 Deployment Patterns
 CI/CD Patterns
 Containers
 … and so on
AWS has helped too!
 Amazon EC2
 EC2 Auto-Scaling
 AWS Elastic Load Balancer
 EC2 Auto-Recovery
 AWS Trusted Advisor
 AWS Elastic Beanstalk
 AWS OpsWorks
 AWS EC2 Container Service
 Etc. Etc. Etc.
But …
many of these tools and innovations are still
coupled to a shared dependency…
Servers
How will the application
handle server hardware failure?
How can I control
access from my servers?
When should I decide to
scale out my servers?
When should I decide to
scale up my servers?
What size servers are
right for my budget?
How much remaining
capacity do my servers have?
(AAHHHHHHHHH!!)
Architect to be Serverless
 Fully Managed
 No provisioning
 Zero administration
 High availability
 Developer Productivity
 Focus on the code that matters
 Innovate rapidly
 Reduce time to market
 Continuous Scaling
 Automatically
 Scale up and scale down
Serverless, event-driven compute service
Lambda = microservice without servers
Enter AWS Lambda
Components of Lambda
 A Lambda Function (that you write)
 An Event Source
 The AWS Lambda Service
 The Function Networking Environment
The Lambda Function
 Your Code (Java, NodeJS, Python)
 The IAM role that code assumes during execution
 The amount of memory allocated to your code (affects
CPU and Network as well)
A valid, complete
Lambda function
An Event Source
Many AWS services can be an event source today:
 S3
 Kinesis
 SNS
 DynamoDB
 CloudWatch
 Config Rules
 Amazon Al
 … and many more
 …and, of course, Amazon API Gateway (more later)
The AWS Lambda Service
 Runs your function code without you managing or
scaling servers.
 Provides an API to trigger the execution of your function.
 Ensures function is executed when triggered, in parallel,
regardless of scale.
 Provides additional capabilities for your function
(logging, monitoring).
The Function Networking Environment
 Default - a default network environment within VPC is provided for you
 Access to the internet always permitted to your function
 No access to VPC-deployed assets
 Customer VPC - Your function executes within the context of your own VPC.
 Privately communicate with other resources within your VPC.
 Familiar configuration and behavior with:
 Subnets
 Elastic Network Interfaces (ENIs)
 EC2 Security Groups
 VPC Route Tables
 NAT Gateway
“Hold on…”
Lots of existing ways to abstract away servers
 SaaS
 PaaS
 MBaaS
 *aaS
 Application Engines/Platforms
What’s unique about Lambda?
 Abstraction at the code/function level (arbitrary, flexible,
familiar)
 The security model (IAM, VPC)
 The community
 Integration with the AWS Service ecosystem!
 Scale
 Triggers
 The pricing model
Continuous
Scaling
No Servers to
Manage
Subsecond
Metering
Benefits of AWS Lambda for building
serverless backends
1 2 3
Many Serverless Options on AWS
Compute Storage
Database
Network
Gateways
Internet of Things
Messaging and Queues
Machine LearningStreaming Analytics
Content Delivery
Security
User Management
Monitoring & Logging
Example Serverless
Architecture
PlayOn! Sports – Video stream processing
Laptop
Encoders
HLS
S3
Playback
VOD Stream
mobile client
CloudFront
Streaming
Live stream
mobile client
CloudFront S3 Ingest
480p
Transcode
HQ Copy
360p
Transcode
Audio-only
Transcode
Thumbnail
QOS
Analytics
Cascading Lambda Functions
http://www.slideshare.net/AmazonWebServices/arc308-the-serverless-company-using-aws-lambda
But…
… in order to utilize Lambda, do I really need to architect
event-driven applications?
… is there a way I can use this construct to built multi-
tier SOA applications?
Enter Amazon API Gateway
Create Configure Publish
Maintain Monitor Secure
Serverless Architecture Patterns
Microservices
Mobile Backend
Web Applications
Real-time Analytics Engine
Serverless Best Practices
AWS Lambda Best Practices
 Limit your function size – especially for Java (starting the JVM
takes time)
 Node – remember execution is asynchronous.
 Don’t assume function container reuse – but take advantage of it
when it does occur.
 Don’t forget about disk (500MB /tmp directory provided to each
function)
 Use the included logger (include details from service-provided
context)
 Create custom metrics (operations-centric, and business-centric)
Amazon API Gateway Best Practices
 Use Mock integrations
 Combine with Cognito for managed end user-based access control.
 Use stage variables (inject API config values into Lambda functions
for logging, behavior)
 Use request/response mapping templates everywhere within
reason, not passthrough.
 Take ownership of HTTP response codes
 Use Swagger import/export for cross-account sharing
Additional Best Practices
 Use strategic, consumable naming conventions (Lambda function
names, IAM roles, API names, API stage names, etc.)
 Use naming conventions and versioning to create automation.
 Externalize authorization to IAM roles whenever possible
 Least privilege and separate IAM roles
 Externalize configuration – DynamoDB is great for this.
 Contact AWS Support before known large scaling events
 Be aware of service throttling, engage AWS support if so.
A Call to Action
Let’s build something Serverless …
AWS Lambda
Function
web browser
Amazon S3
Amazon API
Gateway
Dynamic Content
Serverless Website
Amazon
DynamoDB
https://aws.amazon.com/blogs/compute/the-squirrelbin-architecture-a-
serverless-microservice-using-aws-lambda/
<shameless-pitch>
In case you didn’t guess …
We’re hiring!
Email lambda-jobs@amazon.com
</shameless-pitch>
Thank you!
https://www.linkedin.com/in/vyomnagrani
@vyomnagrani
Demo
Walkthrough of a simple CRUD backend with a
RESTful API endpoint using AWS Lambda
Amazon API
Gateway
AWS Lambda Amazon
DynamoDB
API call from
client app
Request/Response CRUD Operations
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
CRUD operations with DynamoDB
‘echo’ and ‘pong’ for testing
Error handling for incorrect inputs
Execute the operation with the event payload
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
Getting Started with Serverless Architectures
1 of 52

More Related Content

What's hot(20)

Serverless ArchitectureServerless Architecture
Serverless Architecture
Elana Krasner1.1K views
AWS LambdaAWS Lambda
AWS Lambda
Scott Leberknight13.1K views
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
Amazon Web Services947 views
Serverless computingServerless computing
Serverless computing
Dmitriy Ivanov401 views
Fundamentals of Cloud Computing & AWSFundamentals of Cloud Computing & AWS
Fundamentals of Cloud Computing & AWS
Bhuvaneswari Subramani185 views
AWS WAFAWS WAF
AWS WAF
Amazon Web Services6.7K views
Serverless Computing Serverless Computing
Serverless Computing
Rushi Namani600 views
AWS Cloud WatchAWS Cloud Watch
AWS Cloud Watch
zekeLabs Technologies4.1K views
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day Israel
Amazon Web Services3K views
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services1.4K views
AWS Monitoring & LoggingAWS Monitoring & Logging
AWS Monitoring & Logging
Jason Poley6.8K views
AWS Serverless Introduction (Lambda)AWS Serverless Introduction (Lambda)
AWS Serverless Introduction (Lambda)
Ashish Kushwaha322 views
AWS LambdaAWS Lambda
AWS Lambda
Muhammed YALÇIN715 views
AWS API GatewayAWS API Gateway
AWS API Gateway
Muhammed YALÇIN644 views

Viewers also liked(20)

Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services4.3K views
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services1.9K views
Serverless architectureServerless architecture
Serverless architecture
Amazon Web Services3.2K views
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services3.9K views
AWS Lambda and the Serverless CloudAWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless Cloud
Amazon Web Services10.2K views
AWS Mobile with Lambda and SNSAWS Mobile with Lambda and SNS
AWS Mobile with Lambda and SNS
Amazon Web Services2.9K views
Securing Serverless ArchitectureSecuring Serverless Architecture
Securing Serverless Architecture
Amazon Web Services1.3K views
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS Lambda
Amazon Web Services10.4K views
Serverless presentationServerless presentation
Serverless presentation
jasonsich1.7K views
Serverless Frameworks on AWSServerless Frameworks on AWS
Serverless Frameworks on AWS
Julien SIMON1.9K views
Serverless ArchitectureServerless Architecture
Serverless Architecture
Lena Barinova1K views

Similar to Getting Started with Serverless Architectures(20)

Primeros pasos con arquitecturas serverlessPrimeros pasos con arquitecturas serverless
Primeros pasos con arquitecturas serverless
Amazon Web Services564 views
SMC301 The State of Serverless ComputingSMC301 The State of Serverless Computing
SMC301 The State of Serverless Computing
Amazon Web Services9.1K views

More from Amazon Web Services(20)

Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services2.8K views
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services7K views
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services3.1K views
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services2.4K views
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services1.4K views
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
Amazon Web Services887 views
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services2.7K views

Recently uploaded(20)

Getting Started with Serverless Architectures

  • 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Vyom Nagrani Manager Product Management, AWS Lambda 30th March, 2016 Getting Started with Serverless Architectures
  • 2. Agenda  Background  AWS Lambda  Amazon API Gateway  Serverless Architecture Patterns  Serverless Best Practices
  • 3. Background How serverless architecture patterns with AWS Lambda are the next evolution of application design
  • 5. The Monolithic Application • Lots of Collateral Damage • All-for-one and one-to-fail • Slipped timelines • Operational issues • Deploy Less Frequently • Less disruption • More time to plan Reduce Risk
  • 8. The Service Oriented Architecture Presentation Tier Logic Tier Data Tier
  • 10. Tools to help this pattern are VAST  Web Servers  Code Libraries  Web Service/Application Frameworks  Configuration Management Tools  API Management Platforms  Deployment Patterns  CI/CD Patterns  Containers  … and so on
  • 11. AWS has helped too!  Amazon EC2  EC2 Auto-Scaling  AWS Elastic Load Balancer  EC2 Auto-Recovery  AWS Trusted Advisor  AWS Elastic Beanstalk  AWS OpsWorks  AWS EC2 Container Service  Etc. Etc. Etc.
  • 12. But … many of these tools and innovations are still coupled to a shared dependency…
  • 13. Servers How will the application handle server hardware failure? How can I control access from my servers? When should I decide to scale out my servers? When should I decide to scale up my servers? What size servers are right for my budget? How much remaining capacity do my servers have? (AAHHHHHHHHH!!)
  • 14. Architect to be Serverless  Fully Managed  No provisioning  Zero administration  High availability  Developer Productivity  Focus on the code that matters  Innovate rapidly  Reduce time to market  Continuous Scaling  Automatically  Scale up and scale down
  • 15. Serverless, event-driven compute service Lambda = microservice without servers Enter AWS Lambda
  • 16. Components of Lambda  A Lambda Function (that you write)  An Event Source  The AWS Lambda Service  The Function Networking Environment
  • 17. The Lambda Function  Your Code (Java, NodeJS, Python)  The IAM role that code assumes during execution  The amount of memory allocated to your code (affects CPU and Network as well) A valid, complete Lambda function
  • 18. An Event Source Many AWS services can be an event source today:  S3  Kinesis  SNS  DynamoDB  CloudWatch  Config Rules  Amazon Al  … and many more  …and, of course, Amazon API Gateway (more later)
  • 19. The AWS Lambda Service  Runs your function code without you managing or scaling servers.  Provides an API to trigger the execution of your function.  Ensures function is executed when triggered, in parallel, regardless of scale.  Provides additional capabilities for your function (logging, monitoring).
  • 20. The Function Networking Environment  Default - a default network environment within VPC is provided for you  Access to the internet always permitted to your function  No access to VPC-deployed assets  Customer VPC - Your function executes within the context of your own VPC.  Privately communicate with other resources within your VPC.  Familiar configuration and behavior with:  Subnets  Elastic Network Interfaces (ENIs)  EC2 Security Groups  VPC Route Tables  NAT Gateway
  • 22. Lots of existing ways to abstract away servers  SaaS  PaaS  MBaaS  *aaS  Application Engines/Platforms
  • 23. What’s unique about Lambda?  Abstraction at the code/function level (arbitrary, flexible, familiar)  The security model (IAM, VPC)  The community  Integration with the AWS Service ecosystem!  Scale  Triggers  The pricing model
  • 24. Continuous Scaling No Servers to Manage Subsecond Metering Benefits of AWS Lambda for building serverless backends 1 2 3
  • 25. Many Serverless Options on AWS Compute Storage Database Network Gateways Internet of Things Messaging and Queues Machine LearningStreaming Analytics Content Delivery Security User Management Monitoring & Logging
  • 27. PlayOn! Sports – Video stream processing Laptop Encoders HLS S3 Playback VOD Stream mobile client CloudFront Streaming Live stream mobile client CloudFront S3 Ingest 480p Transcode HQ Copy 360p Transcode Audio-only Transcode Thumbnail QOS Analytics Cascading Lambda Functions http://www.slideshare.net/AmazonWebServices/arc308-the-serverless-company-using-aws-lambda
  • 28. But… … in order to utilize Lambda, do I really need to architect event-driven applications? … is there a way I can use this construct to built multi- tier SOA applications?
  • 29. Enter Amazon API Gateway Create Configure Publish Maintain Monitor Secure
  • 36. AWS Lambda Best Practices  Limit your function size – especially for Java (starting the JVM takes time)  Node – remember execution is asynchronous.  Don’t assume function container reuse – but take advantage of it when it does occur.  Don’t forget about disk (500MB /tmp directory provided to each function)  Use the included logger (include details from service-provided context)  Create custom metrics (operations-centric, and business-centric)
  • 37. Amazon API Gateway Best Practices  Use Mock integrations  Combine with Cognito for managed end user-based access control.  Use stage variables (inject API config values into Lambda functions for logging, behavior)  Use request/response mapping templates everywhere within reason, not passthrough.  Take ownership of HTTP response codes  Use Swagger import/export for cross-account sharing
  • 38. Additional Best Practices  Use strategic, consumable naming conventions (Lambda function names, IAM roles, API names, API stage names, etc.)  Use naming conventions and versioning to create automation.  Externalize authorization to IAM roles whenever possible  Least privilege and separate IAM roles  Externalize configuration – DynamoDB is great for this.  Contact AWS Support before known large scaling events  Be aware of service throttling, engage AWS support if so.
  • 39. A Call to Action
  • 40. Let’s build something Serverless … AWS Lambda Function web browser Amazon S3 Amazon API Gateway Dynamic Content Serverless Website Amazon DynamoDB https://aws.amazon.com/blogs/compute/the-squirrelbin-architecture-a- serverless-microservice-using-aws-lambda/
  • 41. <shameless-pitch> In case you didn’t guess … We’re hiring! Email lambda-jobs@amazon.com </shameless-pitch>
  • 43. Demo
  • 44. Walkthrough of a simple CRUD backend with a RESTful API endpoint using AWS Lambda Amazon API Gateway AWS Lambda Amazon DynamoDB API call from client app Request/Response CRUD Operations
  • 47. CRUD operations with DynamoDB ‘echo’ and ‘pong’ for testing Error handling for incorrect inputs Execute the operation with the event payload