This presentation is from the AWS Lambda session of Container Days Conference in NYC. AWS Lambda is a new compute service that runs your code in response to events and automatically and dynamically manages infra resources for you. Tara will talk about AWS's event-driven compute strategy and explain how Lambda works to respond to events from various Amazon services.
Tara will describe what you need to easily build scalable microservices for mobile, web, and IoT applications that use AWS Lambda as a serverless back-end, how you can expose these services using Amazon API Gateway, and how to extend both AWS and third party services by triggering Lambda functions. She'll also cover the updated Lambda features announced at reInvent 2015, its programming model, and tips on getting the most out of Lambda.
2. AWS Compute offerings
Lambda
Serverless compute
platform for stateless
code execution in
response to Triggers
ECS
Container
management service
for running Docker on
a managed cluster of
EC2
EC2
Virtual servers
in the Cloud
3. AWS Lambda Overview
A compute service where you
don’t have to think about:
• Servers
• Being over/under capacity
• Deployments
• Scaling and fault tolerance
• OS or language updates
• Metrics and logging
…but where you can easily
• Bring your own code…
even native libraries
• Run code in parallel
• Create backends, event
handlers, and data
processing systems
• Never pay for idle!
11. Amazon Simple Email Service Inbound Rules
// Spam check
if (sesNotification.receipt.spamVerdict.status === 'FAIL‘ ||
sesNotification.receipt.virusVerdict.status === 'FAIL')
console.log('Dropping spam');
12. Amazon CloudWatch Logs Processing
Scan, audit, or index log entries in near real time
AWS LambdaAmazon CloudWatch
Logs
Amazon
DynamoDB
Amazon S3
Amazon
Redshift
13. Lambda update: 5 new features announced
earlier this month at re:Invent 2015
1. Python functions
2. Increased function duration
3. Function versioning & aliasing
4. Scheduled functions (Cron)
5. Accessing Resources in a VPC From a Lambda Function
[coming soon]
Details at: https://aws.amazon.com/blogs/aws/aws-lambda-update-
python-vpc-increased-function-duration-scheduling-and-more/
16. Python 2.7 Support in AWS Lambda
• Available today in
• All SDKs (including mobile SDKs)
• AWS CLI
• Lambda console (including interactive editing)
• Includes
• Version 1.1.3 of boto3 (AWS Python SDK)
• Documentation and walkthroughs
• Console blueprints
18. Longer-running AWS Lambda Functions
• Run functions for up to 5 minutes
• Available today in the following SDKs
• Python (boto3)
• Java
• Node.js
• PHP
• AWS Mobile SDK for Android
• AWS Mobile SDK for iOS
19. Resource Sizing
• AWS 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
• Higher power levels == lower latency for CPU-bound
and bursty tasks
• Compute price scales with the power level
• Duration ranging from 100ms to 5 minutes
• Free Tier: 1M free requests and 400,000 GB-s / month
22. Scheduled AWS Lambda Functions
• Available today in the Lambda console
• Schedule functions at a specific time or recurring
• Accepts standard cron syntax
• 5 minute granularity
• You can get sub-second granularity using a Lambda function
• Easily poll Amazon SQS or other data sources!
• Coming later in 2015: CLI, SDK support
24. 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”);}
25. 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
26. 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
27. 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
28. Amazon API Gateway:
Version your APIs
/prod/my_url_endpoint
MyFunction:prod_rel
Versioning APIs and Code
MyFunction:prod_rel
Function:3
{your code}
AWS Lambda:
Version your code
32. Sneak Peek: Accessing Resources in a VPC
From a Lambda Function [Coming soon]
Description: Access resources behind a VPC from inside
Lambda functions
Benefit: You will soon be able to access resources in a
private IP range in your VPC, including EC2, ELB, RDS,
ElastiCache and Redshift
How it works: When creating Lambda functions, you will be
able to select the VPC subnets and security groups, and the
Lambda function executions can then access private
endpoints in that VPC IP range
33. 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
• Launching later this year in all AWS Lambda regions