Post on 07-Jan-2017
©2016, 1Strategy, All rights reserved
LambdaJordan Farrer, 1Strategy
What is Lambda?
• Event-driven managed compute service
• Stateless code execution, no affinity to underlying infrastructure
• Announced November 2014
Benefits of Lambda
• Run code without managing servers
• Infinitely scalable• Built-in high availability• Pay only for what you
use• Zero administration
Sample Scenario
The Traditional Approach
Availability Zone
Availability Zone
Auto Scaling group Auto Scaling group
The Traditional Approach - Responsibilities• Application Code• Infrastructure Provisioning• OS patching• Security• Server bootstrapping• Code deployment• Monitoring• Scaling (manual or autoscaling)• Fault Tolerance/High Availability
The Lambda Solution
The Lambda Solution - Responsibilities
• Application Code
Function Basics
Code Permissions Event
Lambda Function Code
• Execution Environment– Runs on Amazon Linux– AWS SDK included by default
• Available Runtimes– Node.js– Python 2.7– Java 8
• Bring your own libraries– Native library support
Lambda Function Permissions
• IAM Role– Best Practice: Never hardcode
username/password or Access/Secret keys
• Specify granular permissions for each function to other AWS resources– S3– DynamoDB– Kinesis
• Coming Soon: VPC
Lambda Event Sources
S3 Kinesis DynamoDB SNS SES
CloudWatch Logs CloudFormation Scheduled Alexa Skills Kit
Lambda Monitoring
• Built in to Lambda• CloudWatch
Metrics– Invocation Count– Duration– Error Rate
• Logs recorded to CloudWatch Logs
Demo: Lambda
Example Use Case:Security Group Change Notifications
http://www.1strategy.com/blog/security-group-change-notifications/
Lambda Pricing
• Pricing based on memory allocation and number of requests
• CPU, network I/O, disk I/O determined by memory allocation
• Billed in 100ms increments• No hourly, daily, or monthly
minimums• Free Tier
– 400,000 GB-seconds every month
Sample Cost Comparison Assumptions
Sample Scenario• 1 million requests• 1 second processing time per request• Highly-Available
Sample Cost Comparison
Using EC2• 2x t2.micro
– $0.013/hour * 750 hours• Total: $19.50
Using Lambda• 1,000,000 requests
– First million requests are free• 1,000,000 GB-seconds
– 400,000 GB-seconds are free– 600,000 * $0.000001667 per
100ms• Total: $10
API Gateway
API Gateway Overview
• Create, publish, maintain, monitor and secure APIs
• Works with EC2, Lambda, or any web application as the backend
• Pay only for what you use
API Gateway and Lambda
• Built-in controls for throttling• Automatic monitoring through CloudWatch• API Versioning• Using Lambda
– API Gateway becomes an “Event Source”
Demo: API Gateway
Thank You