SlideShare une entreprise Scribd logo
1  sur  49
Télécharger pour lire hors ligne
Presenter Name
Solutions Architect - AWS
Developer Roadshow
Serverless Web Apps using API Gateway,
Lambda and DynamoDB
Agenda
• What is Serverless?
• Introduction to Amazon DynamoDB
• Introduction to Lambda and API Gateway
• Tips and Best Practices
What is Serverless computing?
• VMs
• Machine as the unit of scale
• Abstracts the hardware
• Containers
• Application as the unit of scale
• Abstracts the OS
• Serverless
• Functions as the unit of scale
• Abstracts the language runtime
Amazon ECS
Amazon EC2
AWS Lambda
How do I choose?
• VMs
• “I want to configure machines,
storage, networking, and my OS”
• Containers
• “I want to run servers, configure
applications, and control scaling”
• Serverless
• “Run my code when it’s needed”
ECS
EC2
Lambda
What is Serverless?
Provisioning
and Utilization
Operations
and Management
Scaling Availability and
Fault Tolerance
Removes the need for….
Amazon DynamoDB
Amazon DynamoDB
• Brief history of data processing
• Relational (SQL) vs. non-relational (NoSQL)
• Fully managed features of DynamoDB
Data volume since 2010
• 90% of stored data generated in
last 2 years
• 1 terabyte of data in 2010 equals
6.5 petabytes today
• Linear correlation between data
pressure and technical innovation
• No reason these trends will not
continue over time
Relational (SQL) vs.
non-relational (NoSQL)
Relational vs. non-relational databases
Traditional SQL NoSQL
DB
Primary Secondary
Scale up
DB
DB
DBDB
DB DB
Scale out
SQL vs. NoSQL schema design
NoSQL design optimizes for
compute instead of storage
Product Database
Amazon DynamoDB
Run your business, not your database
Fully managed
Fast, consistent performance
Highly scalable
Flexible
Event-driven programming
Fine-grained access control
DynamoDB benefits
Fully managed service = automated operations
DB hosted on premises DB hosted on Amazon EC2
Fully managed service = automated operations
DB hosted on premises DynamoDB
Consistently low latency at scale
PREDICTABLE
PERFORMANCE!
WRITES
Replicated continuously to 3
Availability Zones
Persisted to disk (custom SSD)
READS
Strongly or eventually consistent
No latency trade-off
Designed to
support 99.99%
of availability
Built for high
durability
High availability and durability
That sounds really good. How
do I get started?
Let’s create a table…
Products
Product_Id
DynamoDB table structure
Table
Items
Attributes
Partition
key
Sort
key
Mandatory
Key-value access pattern
Determines data distribution Optional
Model 1:N relationships
Enables rich query capabilities
All items for key
==, <, >, >=, <=
“begins with”
“between”
“contains”
“in”
sorted results
counts
top/bottom N values
• Stream of updates to a
table
• Asynchronous
• Exactly once
• Strictly ordered
• Per item
DynamoDB Streams
• Highly durable
• Scale with table
• 24-hour lifetime
• Subsecond latency
View Type Destination
Old image—before update Name = John, Destination = Mars
New image—after update Name = John, Destination = Pluto
Old and new images Name = John, Destination = Mars
Name = John, Destination = Pluto
Keys only Name = John
View types
UpdateItem (Name = John, Destination = Pluto)
Triggers
Lambda Function
Notify Change
Derivative Tables
Amazon
CloudSearch
Amazon ElastiCache
AWS Lambda
Components of Lambda
• A Lambda function (that you write)
• An event source
• The AWS Lambda service
• The function networking environment
Lambda Function
• Your code
(Java, NodeJS, Python, C#)
• 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
Event Sources
• When should your function
execute?
• Many AWS services can be
an event source today:
• Amazon S3
• Amazon Kinesis
• Amazon SNS
• Amazon DynamoDB
• Amazon CloudWatch
• AWS Config Rules
• Amazon Echo
• Etc.
• …and Amazon API
Gateway (more later)
AWS Lambda
• 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).
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
AWS Lambda Programming Model
Bring your own code
• Node.js, Java, Python, C#
• Bring your own libraries
(even native ones)
Simple resource model
• Select power rating from
128 MB to 1.5 GB
• CPU and network allocated
proportionately
• Reports actual usage
Programming model
• AWS SDK built in (Python
and Node.js)
• Lambda is the “webserver”
• Use processes, threads,
/tmp, sockets normally
Stateless
• Persist data using Amazon
DynamoDB, S3, or Amazon
ElastiCache
• No affinity to infrastructure
(can’t “log in to the box”)
Using AWS Lambda
Authoring functions
• Author directly using the
console WYSIWYG editor
• Package code as a .zip and
upload to Lambda or S3
• Plugins for Eclipse and
Visual Studio
• Command line tools
Monitoring and logging
• Built-in metrics for requests,
errors, latency, and throttles
• Built-in logs in Amazon
CloudWatch Logs
Flexible authorization
• Securely grant access to
resources, including VPCs
• Fine-grained control over
who can call your functions
Flexible use
• Call or send events
• Integrated with other AWS
services
• Build whole serverless
ecosystems
AWS Lambda Pricing
• Buy compute time in
100 ms increments
• Low request charge
• No hourly, daily, or
monthly minimums
• No per-device fees
Never pay for idle!
Free Tier
1 million requests and 400,000 GBs of
compute every month, every customer
Amazon API Gateway
Introduction to Amazon API Gateway
Create a unified
API frontend for
multiple micro-
services
Authenticate and
authorize
requests to a
backend
DDoS protection
and throttling for
your backend
Throttle, meter,
and monetize API
usage by 3rd
party developers
API Gateway - Capabilities
• Host multiple versions and stages of your APIs
• Create and distribute API keys to developers
• Leverage signature version 4 to authorize access to APIs
• Throttle and monitor requests to protect your backend
• Utilize Lambda as a backend
Benefits of API Gateway
• Managed cache to store API responses
• Reduced latency and distributed denial of service (DDoS) protection
through Amazon CloudFront
• SDK generation for iOS, Android, and JavaScript
• Swagger support
• Request and response data transformation
Amazon API Gateway: Serverless APIs
Internet
Mobile
apps
Websites
Partner
Services
AWS Lambda
functions
API
Gateway
response
cache
Endpoints on
Amazon EC2
Any publicly
accessible
endpoint
Amazon
CloudWatch
Amazon
CloudFront
API
Gateway
Tips and best practices
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 KMS
• Allows you to specify in IAM what roles have access to
the keys to decrypt the information
• Useful for creating environments per stage (such as
dev, testing, production)
AWS Lambda VPC: Best practices
VPC is optional – don’t turn in on unless you need it.
Functions configured for VPC access lose internet access…
• Unless you have managed NAT or a NAT instance in the VPC
The ENIs used by Lambda’s VPC feature count against your quota.
Ensure you have enough to match your peak concurrency levels
(we’ll consolidate where we can).
DO NOT delete or rename these ENIs!
Ensure your subnets have enough IPs for those ENIs.
Specify at least one subnet in each Availability Zone
Otherwise, Lambda will obey, but can’t be as fault-tolerant.
Serverless Deployment
AWS Serverless Application Model (SAM)
CloudFormation extension optimized for
serverless
New serverless resource types: functions, APIs,
and tables
Supports anything CloudFormation supports
Open specification (Apache 2.0)
https://github.com/awslabs/serverless-application-model
SAM template
From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml
<-THIS
BECOMES THIS->
AWS commands – Package & Deploy
Package
•Creates a deployment package (.zip file)
•Uploads deployment package to an Amazon S3 bucket
•Adds a CodeUri property with S3 URI
Deploy
•Calls CloudFormation ‘CreateChangeSet’ API
•Calls CloudFormation ‘ExecuteChangeSet’ API
Common Serverless use cases
Web
Applications
• Static
websites
• Complex web
apps
• Packages for
Flask and
Express
Data
Processing
• Real time
• MapReduce
• Batch
Chatbots
• Powering
chatbot logic
Backends
• Apps &
services
• Mobile
• IoT
</></>
Amazon
Alexa
• Powering
voice-enabled
apps
• Alexa Skills
Kit
Autonomous
IT
• Policy engines
• Extending
AWS services
• Infrastructure
management
Internal only – do not distribute
What’s the same
- Standard languages and protocols
- Standard deployment and testing practices
What's unique
- Event/request driven
- Modular
- Stateless
- Call it 12 factor/Microservices/Reactive..
What that means
- Monoliths need to be broken up
- Consider how functions communicate/ clear
service boundaries
- Need to deal with composition/aggregation
- Need to understand things like building for failure,
eventual consistency
EVENTS
Requests to endpoints
Changes in resource state
Changes in data state
FUNCTIONS
DOWNSTREAM
“Distributed, stateless, ephemeral – what could possibly go wrong?”
Key mindshift – how apps are built
Links:
Serverless: aws.amazon.com/serverless
DynamoDB: aws.amazon.com/dynamodb
Lambda: aws.amazon.com/lambda
API Gateway: aws.amazon.com/api-gateway
me: email@amazon.com
Internal only – do not distribute
IoT Button: http://bit.ly/2rQocXH
Labs: http://bit.ly/2rYXxwH
IoT Button Homework

Contenu connexe

Tendances

Tendances (20)

AWS CloudFormation Masterclass
AWS CloudFormation MasterclassAWS CloudFormation Masterclass
AWS CloudFormation Masterclass
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
A Brief Look at Serverless Architecture
A Brief Look at Serverless ArchitectureA Brief Look at Serverless Architecture
A Brief Look at Serverless Architecture
 
AWS IAM Introduction
AWS IAM IntroductionAWS IAM Introduction
AWS IAM Introduction
 
Serverless with IAC - terraform과 cloudformation 비교
Serverless with IAC - terraform과 cloudformation 비교Serverless with IAC - terraform과 cloudformation 비교
Serverless with IAC - terraform과 cloudformation 비교
 
Build your APPs in Lean and Agile Way using AWS Amplify
Build your APPs in Lean and Agile Way using AWS AmplifyBuild your APPs in Lean and Agile Way using AWS Amplify
Build your APPs in Lean and Agile Way using AWS Amplify
 
Amazon services ec2
Amazon services ec2Amazon services ec2
Amazon services ec2
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
 
AWS IAM과 친해지기 – 조이정, AWS 솔루션즈 아키텍트:: AWS Builders Online Series
AWS IAM과 친해지기 – 조이정, AWS 솔루션즈 아키텍트:: AWS Builders Online Series AWS IAM과 친해지기 – 조이정, AWS 솔루션즈 아키텍트:: AWS Builders Online Series
AWS IAM과 친해지기 – 조이정, AWS 솔루션즈 아키텍트:: AWS Builders Online Series
 
AWS Deployment Best Practices
AWS Deployment Best PracticesAWS Deployment Best Practices
AWS Deployment Best Practices
 
Auto scaling using Amazon Web Services ( AWS )
Auto scaling using Amazon Web Services ( AWS )Auto scaling using Amazon Web Services ( AWS )
Auto scaling using Amazon Web Services ( AWS )
 
03_AWS IoTのDRを考える
03_AWS IoTのDRを考える03_AWS IoTのDRを考える
03_AWS IoTのDRを考える
 
AWS Elastic Beanstalk Tutorial | AWS Certification | AWS Tutorial | Edureka
AWS Elastic Beanstalk Tutorial | AWS Certification | AWS Tutorial | EdurekaAWS Elastic Beanstalk Tutorial | AWS Certification | AWS Tutorial | Edureka
AWS Elastic Beanstalk Tutorial | AWS Certification | AWS Tutorial | Edureka
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
Amazon CloudFront 101
Amazon CloudFront 101Amazon CloudFront 101
Amazon CloudFront 101
 
Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Serverless computing with AWS Lambda
Serverless computing with AWS Lambda
 
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
 
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
 [AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵 [AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
 
AWS SQS SNS
AWS SQS SNSAWS SQS SNS
AWS SQS SNS
 
Identity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS SecurityIdentity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS Security
 

Similaire à Serverless Web Apps using API Gateway, Lambda and DynamoDB

Similaire à Serverless Web Apps using API Gateway, Lambda and DynamoDB (20)

Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
 
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T... Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 
AWS Lambda: Event-driven Code for Devices and the Cloud
AWS Lambda: Event-driven Code for Devices and the CloudAWS Lambda: Event-driven Code for Devices and the Cloud
AWS Lambda: Event-driven Code for Devices and the Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud by Jim Tran, Princip...
Getting Started with AWS Lambda and the Serverless Cloud by Jim Tran, Princip...Getting Started with AWS Lambda and the Serverless Cloud by Jim Tran, Princip...
Getting Started with AWS Lambda and the Serverless Cloud by Jim Tran, Princip...
 
AWS Lambda and Serverless Cloud
AWS Lambda and Serverless CloudAWS Lambda and Serverless Cloud
AWS Lambda and Serverless Cloud
 
Aws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaAws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon Elisha
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
AWS re:Invent 2016: The State of Serverless Computing (SVR311)
AWS re:Invent 2016: The State of Serverless Computing (SVR311)AWS re:Invent 2016: The State of Serverless Computing (SVR311)
AWS re:Invent 2016: The State of Serverless Computing (SVR311)
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Raleigh DevDay 2017: Build a serverless web application in one day workshop
Raleigh DevDay 2017: Build a serverless web application in one day workshopRaleigh DevDay 2017: Build a serverless web application in one day workshop
Raleigh DevDay 2017: Build a serverless web application in one day workshop
 
Getting Started with AWS Lambda and Serverless Computing
Getting Started with AWS Lambda and Serverless ComputingGetting Started with AWS Lambda and Serverless Computing
Getting Started with AWS Lambda and Serverless Computing
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
serverless_architecture_patterns_london_loft.pdf
serverless_architecture_patterns_london_loft.pdfserverless_architecture_patterns_london_loft.pdf
serverless_architecture_patterns_london_loft.pdf
 
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
 

Plus de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Plus de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Serverless Web Apps using API Gateway, Lambda and DynamoDB

  • 1. Presenter Name Solutions Architect - AWS Developer Roadshow Serverless Web Apps using API Gateway, Lambda and DynamoDB
  • 2. Agenda • What is Serverless? • Introduction to Amazon DynamoDB • Introduction to Lambda and API Gateway • Tips and Best Practices
  • 3. What is Serverless computing? • VMs • Machine as the unit of scale • Abstracts the hardware • Containers • Application as the unit of scale • Abstracts the OS • Serverless • Functions as the unit of scale • Abstracts the language runtime Amazon ECS Amazon EC2 AWS Lambda
  • 4. How do I choose? • VMs • “I want to configure machines, storage, networking, and my OS” • Containers • “I want to run servers, configure applications, and control scaling” • Serverless • “Run my code when it’s needed” ECS EC2 Lambda
  • 5. What is Serverless? Provisioning and Utilization Operations and Management Scaling Availability and Fault Tolerance Removes the need for….
  • 7. Amazon DynamoDB • Brief history of data processing • Relational (SQL) vs. non-relational (NoSQL) • Fully managed features of DynamoDB
  • 8. Data volume since 2010 • 90% of stored data generated in last 2 years • 1 terabyte of data in 2010 equals 6.5 petabytes today • Linear correlation between data pressure and technical innovation • No reason these trends will not continue over time
  • 10. Relational vs. non-relational databases Traditional SQL NoSQL DB Primary Secondary Scale up DB DB DBDB DB DB Scale out
  • 11. SQL vs. NoSQL schema design NoSQL design optimizes for compute instead of storage Product Database
  • 12. Amazon DynamoDB Run your business, not your database
  • 13. Fully managed Fast, consistent performance Highly scalable Flexible Event-driven programming Fine-grained access control DynamoDB benefits
  • 14. Fully managed service = automated operations DB hosted on premises DB hosted on Amazon EC2
  • 15. Fully managed service = automated operations DB hosted on premises DynamoDB
  • 16. Consistently low latency at scale PREDICTABLE PERFORMANCE!
  • 17. WRITES Replicated continuously to 3 Availability Zones Persisted to disk (custom SSD) READS Strongly or eventually consistent No latency trade-off Designed to support 99.99% of availability Built for high durability High availability and durability
  • 18. That sounds really good. How do I get started? Let’s create a table…
  • 20.
  • 21. DynamoDB table structure Table Items Attributes Partition key Sort key Mandatory Key-value access pattern Determines data distribution Optional Model 1:N relationships Enables rich query capabilities All items for key ==, <, >, >=, <= “begins with” “between” “contains” “in” sorted results counts top/bottom N values
  • 22. • Stream of updates to a table • Asynchronous • Exactly once • Strictly ordered • Per item DynamoDB Streams • Highly durable • Scale with table • 24-hour lifetime • Subsecond latency
  • 23. View Type Destination Old image—before update Name = John, Destination = Mars New image—after update Name = John, Destination = Pluto Old and new images Name = John, Destination = Mars Name = John, Destination = Pluto Keys only Name = John View types UpdateItem (Name = John, Destination = Pluto)
  • 24. Triggers Lambda Function Notify Change Derivative Tables Amazon CloudSearch Amazon ElastiCache
  • 26. Components of Lambda • A Lambda function (that you write) • An event source • The AWS Lambda service • The function networking environment
  • 27. Lambda Function • Your code (Java, NodeJS, Python, C#) • 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
  • 28. Event Sources • When should your function execute? • Many AWS services can be an event source today: • Amazon S3 • Amazon Kinesis • Amazon SNS • Amazon DynamoDB • Amazon CloudWatch • AWS Config Rules • Amazon Echo • Etc. • …and Amazon API Gateway (more later)
  • 29. AWS Lambda • 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).
  • 30. 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
  • 31. AWS Lambda Programming Model Bring your own code • Node.js, Java, Python, C# • Bring your own libraries (even native ones) Simple resource model • Select power rating from 128 MB to 1.5 GB • CPU and network allocated proportionately • Reports actual usage Programming model • AWS SDK built in (Python and Node.js) • Lambda is the “webserver” • Use processes, threads, /tmp, sockets normally Stateless • Persist data using Amazon DynamoDB, S3, or Amazon ElastiCache • No affinity to infrastructure (can’t “log in to the box”)
  • 32. Using AWS Lambda Authoring functions • Author directly using the console WYSIWYG editor • Package code as a .zip and upload to Lambda or S3 • Plugins for Eclipse and Visual Studio • Command line tools Monitoring and logging • Built-in metrics for requests, errors, latency, and throttles • Built-in logs in Amazon CloudWatch Logs Flexible authorization • Securely grant access to resources, including VPCs • Fine-grained control over who can call your functions Flexible use • Call or send events • Integrated with other AWS services • Build whole serverless ecosystems
  • 33. AWS Lambda Pricing • Buy compute time in 100 ms increments • Low request charge • No hourly, daily, or monthly minimums • No per-device fees Never pay for idle! Free Tier 1 million requests and 400,000 GBs of compute every month, every customer
  • 35. Introduction to Amazon API Gateway Create a unified API frontend for multiple micro- services Authenticate and authorize requests to a backend DDoS protection and throttling for your backend Throttle, meter, and monetize API usage by 3rd party developers
  • 36. API Gateway - Capabilities • Host multiple versions and stages of your APIs • Create and distribute API keys to developers • Leverage signature version 4 to authorize access to APIs • Throttle and monitor requests to protect your backend • Utilize Lambda as a backend
  • 37. Benefits of API Gateway • Managed cache to store API responses • Reduced latency and distributed denial of service (DDoS) protection through Amazon CloudFront • SDK generation for iOS, Android, and JavaScript • Swagger support • Request and response data transformation
  • 38. Amazon API Gateway: Serverless APIs Internet Mobile apps Websites Partner Services AWS Lambda functions API Gateway response cache Endpoints on Amazon EC2 Any publicly accessible endpoint Amazon CloudWatch Amazon CloudFront API Gateway
  • 39. Tips and best practices
  • 40. 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 KMS • Allows you to specify in IAM what roles have access to the keys to decrypt the information • Useful for creating environments per stage (such as dev, testing, production)
  • 41. AWS Lambda VPC: Best practices VPC is optional – don’t turn in on unless you need it. Functions configured for VPC access lose internet access… • Unless you have managed NAT or a NAT instance in the VPC The ENIs used by Lambda’s VPC feature count against your quota. Ensure you have enough to match your peak concurrency levels (we’ll consolidate where we can). DO NOT delete or rename these ENIs! Ensure your subnets have enough IPs for those ENIs. Specify at least one subnet in each Availability Zone Otherwise, Lambda will obey, but can’t be as fault-tolerant.
  • 43. AWS Serverless Application Model (SAM) CloudFormation extension optimized for serverless New serverless resource types: functions, APIs, and tables Supports anything CloudFormation supports Open specification (Apache 2.0) https://github.com/awslabs/serverless-application-model
  • 45. AWS commands – Package & Deploy Package •Creates a deployment package (.zip file) •Uploads deployment package to an Amazon S3 bucket •Adds a CodeUri property with S3 URI Deploy •Calls CloudFormation ‘CreateChangeSet’ API •Calls CloudFormation ‘ExecuteChangeSet’ API
  • 46. Common Serverless use cases Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit Autonomous IT • Policy engines • Extending AWS services • Infrastructure management
  • 47. Internal only – do not distribute What’s the same - Standard languages and protocols - Standard deployment and testing practices What's unique - Event/request driven - Modular - Stateless - Call it 12 factor/Microservices/Reactive.. What that means - Monoliths need to be broken up - Consider how functions communicate/ clear service boundaries - Need to deal with composition/aggregation - Need to understand things like building for failure, eventual consistency EVENTS Requests to endpoints Changes in resource state Changes in data state FUNCTIONS DOWNSTREAM “Distributed, stateless, ephemeral – what could possibly go wrong?” Key mindshift – how apps are built
  • 48. Links: Serverless: aws.amazon.com/serverless DynamoDB: aws.amazon.com/dynamodb Lambda: aws.amazon.com/lambda API Gateway: aws.amazon.com/api-gateway me: email@amazon.com
  • 49. Internal only – do not distribute IoT Button: http://bit.ly/2rQocXH Labs: http://bit.ly/2rYXxwH IoT Button Homework