AWS Lambda enables developers to build scalable applications without managing servers. Come learn how AWS Lambda’s event driven approach helps build backend ingestion systems, real time stream processing, and scalable API backends. We will deep dive and provide live demo into the different approaches that customers have taken to building applications with AWS Lambda, the typical architectures that customers use and best practices for authoring, deploying, and managing the functions.
Markku Lepisto, Principal Technology Evangelist, Amazon Web Services, APAC
12. Versioning: Development
• Developing in AWS Lambda stays simple:
• Upload code
• Make changes any time
• Last update wins
exports.handler =
function(event,context)
{context.succeed(“bye”);}
exports.handler =
function(event,context)
{context.succeed(“hi”);}
13. Versioning: Publishing
• Publish new versions from development at any
time:
• “Copies” dev version to a numbered version
• Published versions are read-only (including configuration)
• Simple, integer counter per function
exports.handler =
function(event,context)
{context.succeed(“bye”);}
exports.handler =
function(event,context)
{context.succeed(“hi”);}
1
2
Versions
14. Versioning: Calling Lambda Functions
• Development version:
FunctionName (or)
FunctionName:$LATEST
• Specific version:
FunctionName:1
FunctionName:2
• Named version:
FunctionName:production
FunctionName:v1_2_3_4
15. Versioning: Aliases
• Create named aliases to any version:
• Allows function owner to map ARNs to code
• Can be updated without changing clients
exports.handler =
function(event,context)
{context.succeed(“bye”);}
exports.handler =
function(event,context)
{context.succeed(“hi”);} prod
dev
Aliases
16. Asynchronous vs Synchronous Function Calls
Asynchronous
• Triggered by events in
AWS Services
• Caller doesn’t wait
Synchronous
• Triggered by your code
• Call the function, wait for
return values
18. Serverless Web Apps
• S3 for serving static content
• Lambda for dynamic content
• API Gateway for https access
• DynamoDB for storage
Dynamic Content
in AWS Lambda
Data Stored in
Amazon
DynamoDB
API GatewayStatic content in
Amazon S3
22. Amazon CloudWatch Logs Processing
Scan, audit, or index log entries in near real time
AWS LambdaAmazon CloudWatch
Logs
Amazon
DynamoDB
Amazon S3
Amazon
Redshift
23. Using Lambda for Automated Infrastructure
Management
AWS
Lambda
Amazon
SNS
Amazon
CloudWatch Alarm
ec2
runInstance
ecs
startTask
beanstalk
updateApp
kinesis
splitShard
Any API call
https://aws.amazon.com/blogs/compute/scaling-amazon-ecs-services-automatically-using-amazon-cloudwatch-and-aws-lambda/
24. Using Lambda to Forward AWS Events to External
Endpoints
http://danilop.net/aws/2015/07/26/sns2ifttt/ | https://github.com/danilop/SNS2IFTTT
AWS
Lambda
Amazon
SNS
IFTTT via
the Maker
channel
Amazon
CloudWatch Events
Auto Scaling
26. Using Lambda to Deploy Lambda Functions
https://aws.amazon.com/blogs/compute/dynamic-github-actions-with-aws-lambda/
AWS
Lambda
Amazon
SNS
GitHub Repo
lambda
createFn ()
27. Real-time Analytics Processing
• Kinesis for high-speed data ingestion
• Store aggregated results in Redshift, S3, DynamoDB
Data Ingestion with
Amazon Kinesis
(PUT record)
Records retrieved by
AWS Lambda
Your code runs once
per [batch of] records
Amazon
S3
Amazon
DynamoDB
Smart
Devices
Click
Stream
Log
Data
Amazon
Redshift
28. AWS Lambda VPC Access
• Select the functions to run in your VPC
• Select subnets and security groups to use
• Your Lambda function can access the private
resources you choose:
• Amazon Elasticache
• Amazon RDS
• Private EC2 endpoints
• Any other resources in your VPC
30. Amazon
Kinesis
Twitter Stream AWS
Lambda
Demo: Live Twitter Feed Analysis
Twitter - On a typical day:
More than 500 million Tweets sent*
• Average 5,700 TPS
Asynchronous Lambda function
triggered by Kinesis records
VPC
32. Resource Sizing
• Lambda offers 23 “power levels”
• Higher levels offer more memory and more CPU
power
– 128 MB & lowest CPU power
– 1.5 GB & highest CPU power
• Choose higher power levels for CPU-bound and
bursty tasks
• Price scales with the power level
33. AWS Lambda Economics
1. Never pay for idle
No cold servers! No cold containers! 100ms billing interval on compute
2. “Lambda is your Ops team” – eliminate fleet deployments, capacity
planning, etc.
3. TCO and productivity – focus on your code, not on infrastructure
and distributed systems logic
4. Free tier:
Free Tier
1 million requests and 400,000 GB-sec of compute.
Every month, every customer.
34. Evolution of Things that Compute
Pets Cattle Sheep Burgers
The shortest development time will win