AWS Lambda is a new compute service that runs your code in response to events and automatically manages compute resources for you. In this session, you learn what you need to get started quickly, including a review of key features, a live demonstration, guidelines on how to use AWS Lambda with Amazon S3 event notifications and Amazon DynamoDB streams, and tips on getting the most out of Lambda functions.
2. Event-Driven Compute in the Cloud
• Launched last November at re:Invent
– Lambda functions: Stateless, request-driven code execution
– Triggered by events…
• PUT to an Amazon S3 bucket
• Write to an Amazon DynamoDB table
• Record in an Amazon Kinesis stream
– Making it easy to…
• Transform data as it reaches the cloud
• Perform data-driven auditing, analysis, and notification
• Kick off workflows
4. No infrastructure to manage
• Focus on business logic,
not infrastructure
• Upload your code; AWS
Lambda handles:
• Capacity
• Scaling
• Deployment
• Monitoring
• Logging
• Web service frontend
• Security patching
5. Bring your own code
• Create threads and
processes, run batch
scripts or other
executables, and
read/write files in /tmp
• Include any library with
your Lambda function
code, even native
libraries
6. Dynamic content generation
based on incoming news text
and images
Real-time log
processing for
prediction analytics
Thumbnailing
installation site photos
for mobile use
Real-time processing and
recording of inbound traffic from
a range of social media
platforms
Large-scale distributed
search across blog
content
Operational
analytics and real-
time troubleshooting
7. 4/9: Building Backends with Lambda
• GA release
• Request/response
• AWS Mobile SDK
• Easy personalization
– …for devices
– …for end users
• New event sources:
Amazon SNS and
Amazon Cognito
AWS LambdaMobile app
8. Sending SNS Messages to AWS Lambda
• Amazon Simple Notification Service (SNS)
– Easily target, route, transform, filter, or audit messages
– Trigger an AWS Lambda function by sending it notifications
– Turn Amazon CloudWatch alarms into actions
– GitHub bots!
Lambda functionSNS
9. Automatic Scaling
• Lambda scales to match
the event rate
• Don’t worry about over
or under provisioning
• Pay only for what you
use
• New app or successful
app, Lambda matches
your scale
10. Fine-grained pricing
• Buy compute time in
100ms increments
• Low request charge
• No hourly, daily, or
monthly minimums
• No per-device fees
Never pay for idle
Free Tier
1M requests and 400,000 GBs of compute
Every month, every customer
11. 6/15: Java Support
• “java8” as a supported language
• AWS Compute blog post on using Scala (Clojure
blog coming soon)
• Eclipse and maven integration
• POJOs for AWS event sources
• Three programming model options: streams,
POJOs, JSON
14. Writing Lambda Functions
• The basics
– Stock node.js or jvm (or call out to Python or a shell script)
– AWS SDK: built-in for node, deployed automatically in Eclipse+Java
– Call directly or wire up events: Lambda handles inbound traffic
• Stateless
– Use S3, DynamoDB, or other Internet storage for persistent data
– Don’t expect affinity to the infrastructure (you can’t “log in to the box”)
• Familiar
– Use processes, threads, /tmp, sockets, …
– Bring your own libraries, even native ones
15. Retry Policies
• Synchronous calls
– Client controls retry behavior
• Events sent from Amazon S3 or SNS:
– One event per Lambda invocation, 3 attempts
• DynamoDB and Amazon Kinesis records:
– Ordered model with multiple records per event
– Unlimited retries (until data expires)
– Shards processed in parallel
16. Lambda Use Cases
“I want to send
customized
messages to
different users”
SNS + Lambda
“I want to send an
offer when a user
runs out of lives in
my game”
Cognito + Lambda
+ SNS
“I want to transform
the records in a
click stream or an
IoT data stream”
Kinesis + Lambda
17. Lambda Use Cases
“I want to take
action on a GitHub
pull”
GitHub + SNS +
Lambda
“I want to scan files
added to an S3
bucket and index
them”
S3 + Lambda +
DynamoDB
“I want to audit all
AWS API usage”
CloudTrail + S3 +
Lambda
18. 6/25: Compute for Connected Devices
• Alexa Skills Kit – build
voice-enabled apps
• Uses AWS Lambda
as a connected
device/IoT platform
22. From Demo to Production with Lambda
Eliminating the distance between
“Works on my box” and “Ship it to customers!”
Never pay
for idle
Built-in
web server
Auto patch
Auto deploy
Auto scale
Built-in
monitoring
Built-in
logging
24. But Wait, There’s More!
• CloudTrail support for AWS Lambda APIs
• CloudFormation stacks can include Lambda
functions
– …and custom actions can run as Lambda functions
• Mobile SDK support for Lambda APIs
• Cross-account access
• Built-in simplified database backend
• Create or update functions from Amazon S3
• Searching, time sorting, and integrated view for logs