aws april webinar series - aws lambda: event-driven code for devices and the cloud

28
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tim Wagner, AWS Lambda General Manager April 30, 2015 AWS Lambda: Event-driven Code for Devices and the Cloud

Upload: amazon-web-services

Post on 18-Jul-2015

809 views

Category:

Technology


1 download

TRANSCRIPT

© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Tim Wagner, AWS Lambda General Manager

April 30, 2015

AWS Lambda: Event-driven

Code for Devices and the Cloud

Event-Driven Compute in the Cloud

Launched last November at re:Invent

• Lambda functions: Stateless, request-driven code execution

• Triggered by events in other services:

• PUT to an Amazon S3 bucket

• Write to an Amazon DynamoDB table

• Record in an Amazon Kinesis stream

• Makes it easy to…

• Transform data as it reaches the cloud

• Perform data-driven auditing, analysis, and notification

• Kick off workflows

Data Triggers: Amazon S3

Amazon S3

Bucket Events

AWS Lambda

Original

image

Thumbnailed

image

1

2

3

Data Triggers: Amazon DynamoDB

AWS LambdaAmazon DynamoDB

Table and Stream

Send SNS

notifications

Update another table

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

Building Backends with Lambda

Mobile Compute• Request/response

• AWS Mobile SDK

• Easy Personalization

…for devices

…for end users

AWS LambdaMobile App

Event-Driven Compute in the Cloud and for Devices

Request / response

• Create instantly scalable backends for mobile apps

• Run stateless computations for web apps without servers

• Build cloud-based IoT ecosystems using C/C++ libraries

• Complements the existing asynchronous functionality

AWS Mobile SDK

Build high quality mobile apps quickly and easily.

AWS Lambda now available in:

• AWS mobile SDK for Android

• AWS iOS mobile SDK

Easy Personalization

Which app/device is she using?

Which end user is this?

Name and version of app,

Make and model of device,

Platform and local, …

Cognito identity,

Cognito identity pool?

?

Demo: Building a Mobile

Backend with AWS Lambda

No Infrastructure to Manage

Focus on business logic, not infrastructure

Upload your code; AWS Lambda handles

• Capacity

• Scaling

• Deployment

• Monitoring

• Logging

• Web service front end

• Security patching

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

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.

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 GB-s of compute.

Every month, every customer.

Using AWS Lambda

Calling Lambda Functions

Call from mobile or web apps

• Wait for a response or just send an event and keep going

• AWS SDK, AWS Mobile SDK, REST API, CLI

Send events from Amazon S3 or SNS:

• One event per Lambda invocation, 3 attempts

Process DynamoDB changes or Amazon Kinesis records as events:

• Ordered model with multiple records per event

• Unlimited retries (until data expires)

Default limits

• 100 concurrent executions and 1,000 invokes per second

• Increases available via AWS customer service!

Writing Lambda Functions

The Basics

• Stock node.js

• AWS SDK comes built in and ready to use

• 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

Configuring the Lambda Functions

1. Pick a name.

2. Pick a size.

• Set memory to any size from 128MB to 1GB, in 64MB steps

• Receive an equivalent portion of other resources (disk, network, compute

power, etc.)

• Easy, single-dial solution to set price/performance preference.

• Lambda tells you how much memory you used, so you can tune this setting.

3. Pick an event source (or several).

AWS Lambda or EC2 / ECS?

AWS Lambda

• Request-driven

• Prioritizes ease of use – one

OS, default hardware choice

• AWS owns and manages the

infrastructure

• Implicit scaling; just make

requests

Amazon EC2 and ECS

• Infrastructure rental

• Flexible – choose instance

type, OS, language, …

• You own and configure the

infrastructure

• Scale by provisioning

instances or containers

New Features

New AWS Event Sources for 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

Lambda

Function

SNS

New AWS Event Sources for Lambda

Amazon Cognito

• Before: Easily synchronize user data across their devices

• Now: Take action when that data changes

• Examples: Verify and respond to game state updates

Lambda

Function

Cognito

How Can You Use These Features?

“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

New Features

Cross-account access support• Create functions that you can share with others

• Send events from S3 buckets in a different AWS account

AWS CloudTrail integration

• Track AWS Lambda API calls in AWS CloudTrail logs

• Audit access logs easily with a Lambda function

AWS CloudFormation Custom Resources

• Run a Lambda function any time you create, update, or delete a CloudFormation stack

• Easily run custom actions without provisioning infrastructure

Improved Metrics and Diagnostics

Discover and take action with free metrics

• AWS Lambda automatically monitors your functions

• Amazon CloudWatch metrics for requests, errors, running time

• New concurrent request throttle metric

Automated logging with time-based sorting

• AWS Lambda automatically logs for you

• Sort CloudWatch Logs by time of last entry

• See creation time in log stream names and easily filter on it

Coming Soon: Java!

You can already call Java programs from Lambda functions

today…

• Java and other languages are automatically included in your

filesystem view…don’t wait to start using them!

• Freezing ensures you don’t pay repeatedly for JVM boot

We’ll make this even easier with built-in support for AWS

Lambda functions written in Java.

Three Next Steps

1. Go to the AWS console to create and test your first Lambda

function. The first 1M requests each month are on us!

2. Use AWS Lambda to add custom logic to S3, DynamoDB,

SNS, Kinesis, or Cognito events…no servers required!

3. Use the AWS Mobile SDK and Lambda to quickly create an

instantly scalable mobile app. Start by visiting

http://aws.amazon.com/mobile/sdk

Visit http://aws.amazon.com/lambda, the AWS

Compute blog, and the Lambda forum to learn

more and get started using Lambda.

Thank you!