Gone in 60 Seconds
-
Upload
richard-boyd-ii -
Category
Technology
-
view
118 -
download
5
Transcript of Gone in 60 Seconds
4/13/20151 Confidential – Do Not Distribute
Visual Commerce
GONE IN 60 SECONDS
Lambda: The ‘Nicholas Cage’ of AWS
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.
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.
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.
4/13/20155 Confidential – Do Not Distribute
TIME TO GET SERIOUS
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?
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)
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)
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
4/13/201510 Confidential – Do Not Distribute
ROLES
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.
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.
4/13/201513 Confidential – Do Not Distribute
EXAMPLE MODELS
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).
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
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.
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.
4/13/201518 Confidential – Do Not Distribute
LET’S ROLL
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
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
4/13/201521 Confidential – Do Not Distribute
• All demo code can be found here:
• https://github.com/invodo/lambda_demo
DEMO TIME
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
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