gone in 60 seconds

23
4/13/2015 1 Confidential Do Not Distribute Visual Commerce GONE IN 60 SECONDS Lambda: The ‘Nicholas Cage’ of AWS

Upload: richard-boyd-ii

Post on 16-Jul-2015

119 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: Gone in 60 Seconds

4/13/20151 Confidential – Do Not Distribute

Visual Commerce

GONE IN 60 SECONDS

Lambda: The ‘Nicholas Cage’ of AWS

Page 2: Gone in 60 Seconds

4/13/20152 Confidential – Do Not Distribute

WHO I AM

• Site Reliability

Engineer at Invodo

• In the process of

implementing a CI /

CD workflow with

duck-tape, Jenkins,

Nexus, JIRA,

GitHub, and

Lagavullin.

Page 3: Gone in 60 Seconds

4/13/20153 Confidential – Do Not Distribute

NICHOLAS CAGE

• Nephew of Francis Ford Coppola.

• His last name is a tribute to a comic book character.

• First film was Fast Times at RidgemontHigh.

• Won an Academy Award for Leaving Los Vegas.

• Greatest actor of the 20th Century.

Page 4: Gone in 60 Seconds

4/13/20154 Confidential – Do Not Distribute

AWS LAMBDA

• Nephew of Docker /

containers.

• Name refers an

anonymous function.

• First appearance was

AWS Re:Invent 2014.

• Won over many early

adopters like Netflix.

• ‘Coolest shit in the

world’ according to

Werner Vogels.

Page 5: Gone in 60 Seconds

4/13/20155 Confidential – Do Not Distribute

TIME TO GET SERIOUS

Page 6: Gone in 60 Seconds

4/13/20156 Confidential – Do Not Distribute

• Server-independent code; somewhere

between IaaS and PaaS.

• You assign:

o Memory available to the function.

o Set a timeout value that the function will be given.

o *CPU scales with memory according to an AWS

engineer.

• Lambda functions are written in JavaScript;

future updates will support more languages

(compiled AND interpreted).

WHAT IS LAMBDA?

Page 7: Gone in 60 Seconds

4/13/20157 Confidential – Do Not Distribute

• AWS Events trigger function execution.

• Three event types are supported in either a

PUSH or PULL model:

o PUSH: S3 events trigger a Lambda process.

o PULL: Lambda polls Kinesis.

o PULL: Lambda polls DynamoDB event streams.

• Uses some type of Container to create new

instances of the function which can persist

between executions.

WHAT IS LAMBDA? (CONT’D)

Page 8: Gone in 60 Seconds

4/13/20158 Confidential – Do Not Distribute

• Containers can:

o Shell out to the operating system (Amazon Linux

AMI, a fork of CEntOS).

o Be uploaded as a compressed package of files.

o Reference locally packaged libraries.

o Reference locally packaged binaries.

WHAT IS LAMBDA? (CONT’D)

Page 9: Gone in 60 Seconds

4/13/20159 Confidential – Do Not Distribute

• Limits:

o Maximum RAM: 1024 MB.

o Maximum Timeout: 60 seconds.

o Disk space allocated: 512 MB.

• Pricing:

o Requests: first 1M are free, $0.20 / 1M thereafter.

o Charges per 100ms based on time usage, e.g.

256MB is $0.000000417 per month.

LAMBDA LIMITS AND PRICING

Page 10: Gone in 60 Seconds

4/13/201510 Confidential – Do Not Distribute

ROLES

Page 11: Gone in 60 Seconds

4/13/201511 Confidential – Do Not Distribute

INVOCATION ROLE

• Used to start

Lambda function

execution.

• Has to have

permission to

execute Lambda,

that’s about it.

Page 12: Gone in 60 Seconds

4/13/201512 Confidential – Do Not Distribute

EXECUTION ROLE

• Permissions given

to the Lambda

function during

execution.

• If it needs to read /

write to other AWS

resources add these

to the policy.

Page 13: Gone in 60 Seconds

4/13/201513 Confidential – Do Not Distribute

EXAMPLE MODELS

Page 14: Gone in 60 Seconds

4/13/201514 Confidential – Do Not Distribute

PUSH EXECUTION: S3

• A new object is

placed in an S3

bucket.

• The bucket triggers

a Lambda event

based on the event

type (PUT, POST,

Copy,

CompleteMultiPartU

pload).

Page 15: Gone in 60 Seconds

4/13/201515 Confidential – Do Not Distribute

• When the event is fired a timer begins.

o If the function exits BEFORE the timer (based on

timeout) expires nothing happens.

o If the function FAILS TO EXIT before the timer, the

event could be fired again, leading to multi-delivery.

• Beware of recursion:

o Place a file in a bucket.

o Do something to the file, modifying it.

o Fire another event because we modified a file.

NOTES ABOUT PUSH EXECTION

Page 16: Gone in 60 Seconds

4/13/201516 Confidential – Do Not Distribute

PULL EXECUTION: KINESIS

• Lambda polls a Kinesis stream for events.

• The Invocation Role must have access to

the stream.

• The Execution Role then takes over.

Page 17: Gone in 60 Seconds

4/13/201517 Confidential – Do Not Distribute

PULL EXECUTION: DYNAMODB

• DynamoDB, k/v NoSQL database.

• Puts, updates, deletes are written to an

event stream.

• Lambda then executes based on the event.

Page 18: Gone in 60 Seconds

4/13/201518 Confidential – Do Not Distribute

LET’S ROLL

Page 19: Gone in 60 Seconds

4/13/201519 Confidential – Do Not Distribute

CREATING A LAMBDA

Name of function

Upload or use

a single file

Handler is the

Function name

Execution role

Page 20: Gone in 60 Seconds

4/13/201520 Confidential – Do Not Distribute

• Lambda functions begin with the handler

declaration:

o exports.handler = function(event, context) {

• Lambda functions end with the context.done

function:

o context.done(null,'end');

• You have up to 60 seconds to return the

context.done.

STARTING AND ENDING LAMBDA

Page 21: Gone in 60 Seconds

4/13/201521 Confidential – Do Not Distribute

• All demo code can be found here:

• https://github.com/invodo/lambda_demo

DEMO TIME

Page 22: Gone in 60 Seconds

4/13/201522 Confidential – Do Not Distribute

• Lambda is being used at AWS, Netflix, and

other companies as a replacement for

micro-services.

• The future (6 – 12 months) will see rapid

evolution in this space.

• My prediction: 2015 will be the start of the

‘post-server era’ in cloud computing.

CLOSING

Page 23: Gone in 60 Seconds

4/13/201523 Confidential – Do Not Distribute

• Netflix CPO Talk on Lambda: http://aws.amazon.com/solutions/case-studies/netflix-and-aws-lambda/

• HN Comment Thread on Lambda: https://news.ycombinator.com/item?id=8602936

• Lambda Pricing Page: http://aws.amazon.com/lambda/pricing/

• DyamoDB Streams: https://aws.amazon.com/blogs/aws/dynamodb-streams-preview/

• Building Reactive Apps with Lambda: https://www.airpair.com/lambda/posts/aws-lambda-stream-processing

RESOURCES