aws lambda: event-driven code in the cloud

29
AWS Lambda: Event-driven Code in the Cloud Tom Maddox, Solutions Architect September 24 th , 2015 | London, UK

Upload: amazon-web-services

Post on 16-Apr-2017

2.620 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: AWS Lambda: Event-driven Code in the Cloud

AWS Lambda: Event-driven Code

in the Cloud

Tom Maddox, Solutions Architect

September 24th, 2015 | London, UK

Page 2: AWS Lambda: Event-driven Code in the Cloud

Our customers had some relatively simple problems

Maybe only 10 lines of code

Think thumbnail generation for an image

or

Validating the format of an address

Page 3: AWS Lambda: Event-driven Code in the Cloud

That were solved with pretty complicated solutions

Scaling

Queuing

Deployment

Monitoring

Logging

Patching

Instance upgrades

Page 4: AWS Lambda: Event-driven Code in the Cloud

What if every AWS service could generate events?

What if you could react to those events in a really

simple way?

Page 5: AWS Lambda: Event-driven Code in the Cloud

Event-Driven Compute in the Cloud

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

• Amazon SNS Message received

• Changes in Amazon Cognito data

• Makes it easy to…

• Transform data as it reaches the cloud

• Perform data-driven auditing, analysis, and notification

• Kick off workflows

Page 6: AWS Lambda: Event-driven Code in the Cloud

AWS Lambda – General Availability

• Larger default limits– 100 concurrent executions

– 1,000 invokes per second

– Increases available via AWS customer service

• Preview label removed– Updated API based on feedback during preview

– Multiple Lambda functions per Kinesis stream

Page 7: AWS Lambda: Event-driven Code in the Cloud

Data Triggers: Amazon S3

Amazon S3 Bucket Events AWS Lambda

Original image Image thumbnail

1

2

3

Page 8: AWS Lambda: Event-driven Code in the Cloud

Data Triggers – Amazon Simple Notification Service

Lambda FunctionSNSCloudWatch

Metric

Page 9: AWS Lambda: Event-driven Code in the Cloud

Data Triggers – Amazon Cognito

Lambda FunctionCognito

Page 10: AWS Lambda: Event-driven Code in the Cloud

Data Triggers: Amazon DynamoDB

AWS LambdaAmazon DynamoDB

Table and Stream

Send SNS Push

notifications

Update another table

Page 11: AWS Lambda: Event-driven Code in the Cloud

Data Triggers – Amazon Kinesis

IoT

Device

Kinesis Lambda DynamoDB

Page 12: AWS Lambda: Event-driven Code in the Cloud

Demo: ClickStream processing with with

AWS Lambda

Page 13: AWS Lambda: Event-driven Code in the Cloud

Demo Architecture

Page 14: AWS Lambda: Event-driven Code in the Cloud

What We *Didn’t* Have to Do:

• Provision software or hardware infrastructure

• Plan capacity

• Understand fault tolerance boundaries

• Write code to scale up and out

• Implement monitoring

• Update operating systems or language runtimes

• …

Page 15: AWS Lambda: Event-driven Code in the Cloud

Mobile Compute

Page 16: AWS Lambda: Event-driven Code in the Cloud

Mobile Compute: Building Backends with Lambda

• Request/Response

• AWS Mobile SDK

• Easy Personalization

…for devices

…for end usersAWS LambdaMobile App

Page 17: AWS Lambda: Event-driven Code in the Cloud

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

Page 18: AWS Lambda: Event-driven Code in the Cloud

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

– API Gateway

Page 19: AWS Lambda: Event-driven Code in the Cloud

AWS API Gateway

Page 20: AWS Lambda: Event-driven Code in the Cloud

Easy Personalization

Which device is she using?

?

Which end user is this?

?

Page 21: AWS Lambda: Event-driven Code in the Cloud

Key Benefits

Page 22: AWS Lambda: Event-driven Code in the Cloud

No Infrastructure to Manage Automatically Scaling

Fine Grained PricingBring Your Own Code

Page 23: AWS Lambda: Event-driven Code in the Cloud

Using AWS Lambda

Page 24: AWS Lambda: Event-driven Code in the Cloud

Calling Lambda Functions

• Call from mobile or web apps– Wait for a response or send an event and continue

– 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)

Page 25: AWS Lambda: Event-driven Code in the Cloud

Writing Lambda Functions

• The Basics– Stock node.js or Java

– 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

Page 26: AWS Lambda: Event-driven Code in the Cloud

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

Page 27: AWS Lambda: Event-driven Code in the Cloud

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

Page 28: AWS Lambda: Event-driven Code in the Cloud

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 the AWS Mobile SDK and Lambda to quickly create an

instantly scalable mobile app.

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

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

Page 29: AWS Lambda: Event-driven Code in the Cloud

LONDON