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

Download AWS Lambda: Event-driven Code for Devices and the Cloud

If you can't read please download the document

Upload: amazon-web-services

Post on 15-Apr-2017

1.994 views

Category:

Technology


2 download

TRANSCRIPT

PowerPoint Presentation

Olivier Klein Senior Solutions Architect, AWS1st September 2016AWS LambdaEvent-Driven Code for Devices and the Cloud

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

1

13 Regions35 Availability Zones59 Edge Locations

Continuous ExpansionAWS Global Infrastructure

2

13 Regions35 Availability Zones59 Edge Locations

Continuous ExpansionAWS Global Infrastructure

New!New!

3

AWS LambdaAuto Scaling

Focus on business logic, not infrastructure.Zero Administration

Lambda scales the infrastructure to match the event rateYour Own Code

Run your code highly-available in the cloud in response to events and scale without any servers to manageWrite your own code in JavaScript, Java or Python

No Infrastructure to ManageFocus on business logic, not infrastructureUpload your code; AWS Lambda handlesCapacityScalingDeploymentMonitoringLoggingWeb service front endSecurity patching

Automatic ScalingLambda scales to match the event rateDont worry about over or under provisioningPay only for what you useNew app or successful app, Lambda matches your scale

Fine-Grained PricingFree Tier1M requests and 400,000 GBs of compute.Every month, every customer.Compute time in 100ms incrementsLow request chargeNo hourly, daily or monthly minimumsNo per-device fees

Never pay for idle!

AWS Lambda Event Driven ComputeStateless code called Lambda functionsInvoke Lambda functions straight from your browser or even your mobile appTrigger functions by events (state transitions) in other services:New file in S3New item in DynamoDBNew message in your Kinesis stream

Amazon KinesisAWS Lambda

Amazon S3Amazon DynamoDB

Amazon S3

Amazon DynamoDBAmazon Kinesis

AWS CloudFormationAWS CloudTrail

Amazon CloudWatchAmazon SNSAmazonSESAmazonAPI GatewayAmazon CognitoAWSIoT

AmazonAlexaCron eventsDATA STORESENDPOINTSREPOSITORIESEVENT/MESSAGE SERVICESEvent Sources that integrate with AWS Lambda and the list continues to grow.

Amazon Config

9

AnalyticsOperational managementLive Dashboards

Data workflowsContent managementETL workflows

Interactive BackendsBotsWebhooks

Autonomous ITPolicy enginesInfrastructure management

Multiple Application Types using AWS Lambda

10

Hello World!

DEMO

How to build application backends?

Back-end logicDatabaseMobile

How to build application backends even better?

AWS LambdaAmazon API Gateway

Amazon DynamoDB

Microservice

Amazon API GatewayFully managed and scalable RESTful API gateway servicePowered by our content delivery network via 59 global edge locationsProvides DDoS protection and throttling capabilitiesMultiple API stages which you define (e.g. dev, test, prod)

AWS LambdaAmazon API Gateway

Amazon EC2

AWS API

On-prem server

When to choose API Gateway vs. Direct SDK?Amazon API Gateway adds an additional layer between your app users and your logic and data stores in order to:Back-end logic can be interchanged without app modifications (important for native mobile app)Ability to throttle individual users or requestsProtect against DDoS attacks including counterfeit requests (Layer 7) and SYN floods (Layer 3)Provides a caching layer for your callsEnables CORS for all AWS service for web apps

Introducing ChaliceServerless micro-framework for AWSDeploy APIs quickly via AWS Lambda and Amazon API Gatewaygithub.com/awslabs/chalice$ chalice new-project helloworld$ cat helloworld/app.py

from chalice import Chalice

app = Chalice(app_name="helloworld")

@app.route("/")def index(): return {"hello": "world"}

$ chalice deploy...Your app is available at: https://endpoint/dev

$ curl https://endpoint/dev{"hello": "world"}

AWS Lambda

Simple API with ChaliceAmazon API GatewayPython (Chalice)Postman

TestBuild / Deploy

DEMO

How to get the web app to the browser??

Storage and Delivery of the App

Amazon S3

Amazon CloudFrontAmazon S3Highly available object storageDesigned for 99.999999999% durabilityOffers HTTP / HTTPS endpoint to objectsAmazon CloudFrontContent Delivery Network with 59 edge locations across the worldCaches content on edge locations for low latency

Amazon S3Amazon CloudFrontBrowser

But Lambda is stateless, where to store data?

Amazon DynamoDB

Schemaless Data Model Seamless scalability No storage or throughput limits Consistent low latency performance High durability and availability Replicated across 3 facilities

DynamoDB

tableitems

attributesFully Managed NoSQL Database Service

Serverless App ArchitectureJavaScript SDK

Browser

AmazonS3

AmazonCloudFront

AWS Lambda

AmazonDynamoDB

Amazon API Gateway

Any other AWS Services (e.g. SNS, SES, ElastiCache etc.)

Serverless with AWS

AWS LambdaAmazon API Gateway

Amazon S3

Amazon CloudFrontBrowser

DEMO

Can I keep different versions of my Lambda function?

Versioning

Immutable versions of functionsPer version configurationPer version Cloudwatch metricsCloudwatch Logs contain version attributeAliases to label a version release$LATEST contains latest code

$LATEST(95)STABLETESTING94V93V92

Update Alias to Deploy

$LATEST(95)STABLETESTING94VV9392

Update Alias to Deploy

API Stages

API Gateway Stage Variables

API Gateway Stage Variables

API GatewayLambdaCustom Domain/prod/ResourcesFunctionName:stablehttps://api.example.com/dev/ResourcesFunctionName:$LATESThttps://dev.example.com/qa/ResourcesFunctionName:qahttps://qa.example.com

Pin your environment with stage variables

A few last Best Practices!

Best Practices for Lambda functionsMemoryCPU proportional to memoryIncreasing =memory makes your code execute faster (if CPU bound)

TimeoutIncreasing timeout allows for longer functions, but more wait in case of errorsUnderstand container re-useCold Start, Warm Start, Hot StartIf start time is crucial, create a scheduled function to keep the Lambda function warmBe aware of safety throttlesAWS Lambda has a safety throttle of 100 concurrent function invocationsCan be raised to any limit via our support team

Thank you!Olivier Klein Senior Solutions Architect, AWS1st September 2016