getting started with aws lambda and the serverless cloud

43
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Vyom Nagrani, Manager Product Management, AWS Lambda Ben Kehoe, Cloud Robotics Research Scientist at iRobot AWS Santa Clara Summit, July 13th, 2016 Getting Started with AWS Lambda and the Serverless Cloud

Upload: amazon-web-services

Post on 15-Apr-2017

506 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: Getting Started with AWS Lambda and the Serverless Cloud

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

Vyom Nagrani, Manager Product Management, AWS Lambda

Ben Kehoe, Cloud Robotics Research Scientist at iRobot

AWS Santa Clara Summit, July 13th, 2016

Getting Started with AWS Lambda

and the Serverless Cloud

Page 2: Getting Started with AWS Lambda and the Serverless Cloud

AWS Compute offerings

VM App Function

Service EC2 ECS Lambda

H/W OS Runtime

Unit of scale

Level of

abstraction

Page 3: Getting Started with AWS Lambda and the Serverless Cloud

AWS compute offerings

I want to

configure

machines,

storage,

networking,

and my OS

I want to run

servers,

configure

applications,

and control

scaling

Run my

code when

it’s needed

Service EC2 ECS Lambda

How do I

choose?

Page 4: Getting Started with AWS Lambda and the Serverless Cloud

Agenda

• Why AWS Lambda

• How it works

• Use cases

• Sample architecture

• Customer success story

• Best practices

Page 5: Getting Started with AWS Lambda and the Serverless Cloud

Why AWS Lambda

Page 6: Getting Started with AWS Lambda and the Serverless Cloud

ServersHow will the application

handle server hardware failure?

How can I control

access from my servers?

When should I decide to

scale out my servers?

When should I decide to

scale up my servers?

What size servers are

right for my budget?

How much remaining

capacity do my servers have?

(AAHHHHHHHHH!!)

Page 7: Getting Started with AWS Lambda and the Serverless Cloud

Operations and management Scaling

Provisioning and utilization Availability and fault tolerance

Owning servers means dealing with ...

Page 8: Getting Started with AWS Lambda and the Serverless Cloud

Serverless compute: AWS Lambda

COMPUTE SERVICE

EVENT-DRIVEN

Run arbitrary

code without

managing

servers

Code only runs

when it needs to

run

Page 9: Getting Started with AWS Lambda and the Serverless Cloud

AWS Lambda: Run code in response to events

Lambda functions: Stateless, trigger-based code execution

Triggered by events:

• Direct sync and async API calls

• AWS service integrations

• Third-party triggers

• Many more …

Makes it easy to:

• Perform data-driven auditing, analysis, and notification

• Build back-end services that perform at scale

Page 10: Getting Started with AWS Lambda and the Serverless Cloud

Cost-effective and

efficient

No infrastructure

to manage

Pay only for what you use

Bring your

own code

Productivity-focused compute platform to build powerful, dynamic, modular

applications in the cloud

Run code in standard

languages

Focus on business logic

Benefits of AWS Lambda

1 2 3

Page 11: Getting Started with AWS Lambda and the Serverless Cloud

How it works

Page 12: Getting Started with AWS Lambda and the Serverless Cloud

Using AWS Lambda

Bring your own code

• Node.js, Java, Python

• Bring your own libraries

(even native ones)

Simple resource model

• Select power rating from

128 MB to 1.5 GB

• CPU and network

allocated proportionately

Flexible use

• Synchronous or

asynchronous

• Integrated with other

AWS services

Flexible authorization

• Securely grant access to

resources and VPCs

• Fine-grained control for

invoking your functions

Page 13: Getting Started with AWS Lambda and the Serverless Cloud

Using AWS Lambda

Authoring functions

• WYSIWYG editor or

upload packaged .zip

• Third-party plugins

(Eclipse, Visual Studio)

Monitoring and logging

• Metrics for requests,

errors, and throttles

• Built-in logs to Amazon

CloudWatch Logs

Programming model

• Use processes, threads,

/tmp, sockets normally

• AWS SDK built in

(Python and Node.js)

Stateless

• Persist data using

external storage

• No affinity or access to

underlying infrastructure

Page 14: Getting Started with AWS Lambda and the Serverless Cloud

Application components for serverless apps

EVENT SOURCE FUNCTION SERVICES (ANYTHING)

Changes in

data state

Requests to

endpoints

Changes in

resource state

Node

Python

Java

… more coming soon

Page 15: Getting Started with AWS Lambda and the Serverless Cloud

Amazon

S3

Amazon

DynamoDB

Amazon

Kinesis

AWS

CloudFormation

AWS

CloudTrail

Amazon

CloudWatch

Amazon

SNS

Amazon

SES

Amazon

API Gateway

Amazon

Cognito

AWS

IoT

Amazon

Alexa

Cron events

DATA STORES ENDPOINTS

REPOSITORIES EVENT/MESSAGE SERVICES

Event sources that integrate with AWS Lambda

… and the list will continue to grow!

Page 16: Getting Started with AWS Lambda and the Serverless Cloud

Use cases

Page 17: Getting Started with AWS Lambda and the Serverless Cloud

Analytics

• Operational management

• Live dashboards

Data workflows

• Content management

• ETL workflows

Multiple application types

Interactive back ends

• Bots

• Webhooks

Autonomous IT

• Policy engines

• Infrastructure management

Page 18: Getting Started with AWS Lambda and the Serverless Cloud

Everybody knows this 3-tier web app diagram

https://d0.awsstatic.com/whitepapers/AWS_Serverless_Multi-Tier_Architectures.pdf

Page 19: Getting Started with AWS Lambda and the Serverless Cloud

Here is what that translates to in real life

http://media.amazonwebservices.com/architecturecenter/AWS_ac_ra_web_01.pdf

Page 20: Getting Started with AWS Lambda and the Serverless Cloud

Updated real-world “serverless” architecture

https://s3.amazonaws.com/awslambda-reference-architectures/web-app/lambda-refarch-webapp.pdf

Page 21: Getting Started with AWS Lambda and the Serverless Cloud

Example: Real-time file processing

https://github.com/awslabs/lambda-refarch-fileprocessing

Page 22: Getting Started with AWS Lambda and the Serverless Cloud

Example: Stream processing

https://github.com/awslabs/lambda-refarch-streamprocessing

Page 23: Getting Started with AWS Lambda and the Serverless Cloud

Customer success story:

Serverless IoT with AWS

Lambda @iRobot

@ben11kehoe

Ben Kehoe

Cloud Robotics Research Scientist

iRobot

Page 24: Getting Started with AWS Lambda and the Serverless Cloud

Video stored

separately to make

PPTX size

manageable

Page 25: Getting Started with AWS Lambda and the Serverless Cloud

Serverless

Functions as a service

• No “instances” of any kind

visible in programming

model

• Scales per request

• Never pay for idle

• Fault-tolerant

Page 26: Getting Started with AWS Lambda and the Serverless Cloud

Serverless → distributed by nature

Component graph becomes

call graph

Distributed systems thinking is

required from the start

Event-based architecture

Page 27: Getting Started with AWS Lambda and the Serverless Cloud

Internet of Things

Many autonomous devices in

collaboration

→ distributed

Interacting with the real world

→ event-based

Page 28: Getting Started with AWS Lambda and the Serverless Cloud

AWS

Lambda

Amazon

DynamoDB

Amazon

Redshift

Amazon

Route 53

Amazon VPC

Amazon

CloudWatch

AWS

CloudFormation

AWS

CloudTrail

AWS

Config

AWS IAMAWS KMSAWS WAF

Amazon

Elasticsearch Service

Amazon

Kinesis

Amazon

QuickSight

Amazon

CloudFront

Amazon S3Amazon

Cognito

Amazon

SNS

Amazon API

Gateway

Amazon

SQS

AWS IoT

How iRobot leverages AWS services to support

our features

Page 29: Getting Started with AWS Lambda and the Serverless Cloud

Breadth of AWS ecosystem

opens up additional integration

and innovation

Scalability and

global footprint

Mature technology

companies need

flexibility and insight

Long-term technical partnership

AWS benefits

Page 30: Getting Started with AWS Lambda and the Serverless Cloud

API Gateway

App requests

over HTTPSCRUD

operations

Page 31: Getting Started with AWS Lambda and the Serverless Cloud

IoT

MQTTCRUD

operations

Page 32: Getting Started with AWS Lambda and the Serverless Cloud

IoT

MQTT

MQTT

Presigned

URL

Staging

bucket

Page 33: Getting Started with AWS Lambda and the Serverless Cloud

SQS/CloudWatch Events

CloudWatch event

every 5 minutes

Lambda runs

for 5 minutesSQS queue

Page 34: Getting Started with AWS Lambda and the Serverless Cloud

Breadth of AWS ecosystem

opens up additional integration

and innovation

Scalability and

global footprint

Mature technology

companies need

flexibility and insight

Long-term technical partnership

AWS benefits (recap)

Page 35: Getting Started with AWS Lambda and the Serverless Cloud

Best practices

Page 36: Getting Started with AWS Lambda and the Serverless Cloud

AWS Lambda best practices

Limit your function/code size

Node – remember execution is asynchronous

500 MB /tmp directory provided to each function

Don’t assume function will reuse underlying infrastructure

But take advantage of it when it does occur

You own the logs

Include details from service-provided context

Create custom metrics

Operations-centric vs. business-centric

Page 37: Getting Started with AWS Lambda and the Serverless Cloud

Best practice: Use versions and aliases

Versions = immutable copies of code + properties

Aliases = mutable pointers to versions

Rollbacks

Staged

promotions

“Lock” behavior

for client

Page 38: Getting Started with AWS Lambda and the Serverless Cloud

The function networking environment

Default - a default network environment within VPC is provided for you

Access to the Internet always permitted to your function

No access to VPC-deployed assets

Customer VPC - Your function executes within the context of your own VPC

Privately communicate with other resources within your VPC

Familiar configuration and behavior with:

Subnets

Elastic network interfaces (ENIs)

EC2 security groups

VPC route tables

NAT gateway

Page 39: Getting Started with AWS Lambda and the Serverless Cloud

Additional best practices

Externalize authorization to IAM roles whenever possible

Least privilege and separate IAM roles

Externalize configuration

DynamoDB is great for this

Make sure your downstream setup “keeps up” with Lambda scaling

Limit concurrency when talking to relational databases

Be aware of service throttling

Engage AWS Support to increase your limits

Contact AWS Support before known large scaling events

Page 40: Getting Started with AWS Lambda and the Serverless Cloud

Takeaways

• Many applications can go serverless

• Data processing, back ends, triggers, web hooks

• Lambda functions are opinionated

• State, invocation modes, and deployments

• The ecosystem continues to grow

• Tooling, languages, and application capabilities

Page 41: Getting Started with AWS Lambda and the Serverless Cloud

Next steps

1. Go to console.aws.amazon.com/lambda and create

your first Lambda function. (The first 1M requests are

on us!)

2. Stay up to date with AWS Lambda on the Compute blog

and check out aws.amazon.com/lambda for scenarios

and customer stories.

3. Send us your questions, comments, and feedback on

the AWS Lambda Forums.

Page 42: Getting Started with AWS Lambda and the Serverless Cloud

Remember to complete

your evaluations!

Page 43: Getting Started with AWS Lambda and the Serverless Cloud