AWS - Lambda and API

Download AWS - Lambda and API

Post on 11-Apr-2017

588 views

Category:

Engineering

5 download

Embed Size (px)

TRANSCRIPT

PowerPoint Presentation

Presenter: Vyom Nagrani, Sr. Product Manager, AWS LambdaQ&A Moderator: Ajay Nair, Sr. Product Manager, AWS LambdaAugust 18th, 2015Best Practices: Building Serverless Backends with AWS Lambda and Amazon API Gateway

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

Amazon API Gateway: Build, Deploy, and Manage APIsSDK Generation for iOS, Android and JavaScriptCreate and distribute API Keys to developersLeverage AWS Sigv4 to authorize access to APIsSwagger supportUtilizes AWS LambdaRequest / Response data transformation

2

Benefits of API Gateway for creating RESTful endpoints for deploying services Manage deployments to multiple versions and environmentsDefine and host APIsLeverage Identity and Access Management to authorize access to your cloud resourcesLeverage AWS AuthDDoS protection and request throttling to safeguard your backendManage network traffic

123

AWS Lambda: A compute service that runs your code in response to events Lambda functions: Stateless, trigger-based code execution

Triggered by events:Direct Sync and Async invocations Put to an Amazon S3 bucketAPI Gateway callAnd many more

Makes it easy toBuild back-end services that perform at scale Perform data-driven auditing, analysis, and notification

High performance at any scale; Cost-effective and efficient

No Infrastructure to managePay only for what you use: Lambda automatically matches capacity to your request rate. Purchase compute in 100ms increments.Bring Your Own CodeProductivity focused compute platform to build powerful, dynamic, modular applications in the cloudRun code in a choice of standard languages. Use threads, processes, files, and shell scripts normally. Focus on business logic, not infrastructure. You upload code; AWS Lambda handles everything else.Benefits of AWS Lambda for building a server-less data processing engine123

5

API Gateway + Lambda = Frontend + Backend !

Internet

Mobile Apps

Websites

Services

API Gateway

AWS

API Gateway Cache

Endpoints on Amazon EC2

Any other publicly accessible endpoint

Amazon CloudWatch Monitoring

Amazon CloudFrontAWS Lambda functions

6

Walkthrough of a simple CRUD backend with a RESTful API endpoint using AWS LambdaAmazon API GatewayAWS LambdaAmazon DynamoDBAPI call from client app

Request/ResponseCRUD Operations

7

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

CRUD operations with DynamoDBecho and pong for testingError handling for incorrect inputsRemove operation code from event

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

AWS Console walkthrough of a simple CRUD backend with a RESTful API endpoint using Lambda

Demo site: A simple CRUD backend with a RESTful API endpoint using Amazon API Gateway and AWS Lambda

http://squirrelbin.com/

23

Attaching Lambda functions to RESTful HTTP Endpoints1:1 Mapping: Every API call triggers a stateless Lambda functionAdd caching to API calls to return a cached response instead for duplicate requests

API Gateway concepts: An API is defined as a set of resources and methodsResource: A logical entity that can be accessed within an APIMethod: The combination of a resource path and an HTTP verb such as GET/POST

Automatic Scaling: Both API Gateway and Lambda scale automatically with callsSafety throttle of 100 concurrent Lambda functions, can be increased by AWS Support CenterUser defined standard-rate limit and a burst-rate limit per second for each API method

24

Best practices for creating Lambda functionsMemory: CPU proportional to the memory configuredIncreasing memory makes your code execute faster (if CPU bound)

Timeout: Increasing timeout allows for longer functions, but more wait in case of errors

Retries: For API Gateway, Lambda doesnt retry the function execution, but the Gateway generated SDKs retry throttled requests

Permission model: API Gateway synchronously triggers Lambda, so assign API Gateway a resource policy to invoke Lambda.

Monitoring and Debugging Lambda functionsConsole DashboardLists all Lambda functionsEasy editing of resources, event sources and other settingsAt-a-glance metrics

Metrics in CloudWatchRequestsErrorsLatencyThrottles

Logging in CloudWatch Logs

Using API Gateway Input/Output TransformsFilter output resultsRemove private or unnecessary dataFilter dataset size to improve API performance

GET to POSTRead all query string parameters from your GET request, and create a body to make a POST to your backend

JSON to XMLReceive JSON input and transform it to XML for your backendReceive JSON from a Lambda function and transform it to XML

Managing different versions of your API stackOperate multiple API versions and multiple stages for each version simultaneously

Clone an existing API to start working on the next major version

Set up custom domain names to point directly to a stage

Version Lambda functions, and associate API stage with Lambda function version alias

COMING SOON!

28

Three Next StepsCreate and test your first API. With a few clicks in the AWS Management Console, you can create an API that acts as a front door for applications to access data, business logic, or functionality from your back-end services.

Create and test your first Lambda function. With AWS Lambda, there are no new languages, tools, or frameworks to learn. You can use any third party library, even native ones.

Select Lambda as your backend for your API This gives you an endpoint for your function which can respond to REST calls like GET, PUT and POST without managing any servers.

Thank you!Visit http://aws.amazon.com/api-gateway, the AWS blog, and the API Gateway forum to learn more and get started using API Gateway.Visit http://aws.amazon.com/lambda, the AWS Compute blog, and the Lambda forum to learn more and get started using Lambda.

AWS re:Invent 2015 October 6-9AWS re:Invent is the largest annual gathering of the global cloud community. Whether you are an existing customer or new to the cloud, AWS re:Invent will provide you with the knowledge and skills to refine your cloud strategy, improve developer productivity, increase application performance and security, and reduce infrastructure costs.

Though AWS re:Invent tickets are sold out, you can still register to view the Live Stream Broadcasts of the keynote addresses and select technical sessions on October 7 and October 8. Register now.

Details:Wednesday, October 79:00am - 10:30am PT: Andrew Jassy, Sr. Vice President, AWS11:00am - 5:15pm PT: 5 of the most popular breakout sessions (to be announced)

Thursday, October 89:00am - 10:30am PT: Dr. Werner Vogels, CTO, Amazon11:00am - 6:15pm PT: 6 of the most popular breakout sessions (to be announced)

Register now for the Live Stream Broadcast by submitting your email where prompted on the AWS re:Invent home page.

Stay Connected: Follow event activities on Twitter @awsreinvent (#reinvent), or like us on Facebook.

31