Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Build and run applications without thinking about servers

123 views

Published on

Organizations need to gain insight and knowledge from a growing number of Internet of Things (IoT) APIs clickstreams comprised of unstructured and log data sources. However, organizations are often limited by legacy data warehouses and ETL processes that were designed for transactional data. In this session, we’ll introduce the key ETL features of AWS Glue through use cases ranging from scheduled nightly data warehouse loads to near real-time, event-driven ETL flows for your data lake. We’ll also discuss how to build scalable, efficient and serverless ETL pipelines using AWS Glue.

  • Be the first to comment

  • Be the first to like this

Build and run applications without thinking about servers

  1. 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Danilo Poccia Evangelist, Serverless, Amazon Web Services Martin Buberl VP of Engineering, Trustpilot Serverless Computing: Build and run applications without thinking about servers
  2. 2. Serverless Means … No servers to provision or manage Scales with usage Never pay for idle Built-in availability and fault tolerance
  3. 3. Serverless Applications Services (anything) Changes in data state Requests to endpoints Changes in resource state Event source Lambda function Node.js Python Java C# Go
  4. 4. Services for Building Serverless Applications AWS Lambda Amazon DynamoDB Amazon SNS Amazon API Gateway Amazon SQS Amazon Kinesis Amazon S3 Compute and API Proxy AWS X-Ray AWS Step Functions Datastores, Storage, Orchestration, Analytics, Interprocess Messaging Developer Tools AWS CodeBuild AWS CodePipeline AWS Serverless Application Model (SAM) Open Source and third parties Lambda@Edge AWS Cloud9 Amazon Aurora Serverless (preview) AWS AppSync
  5. 5. Common Serverless Application Use Cases Web applications • Static websites • Complex web apps • Packages for Flask and Express Data processing • Real time • MapReduce • Batch • Machine learning inference Chatbots • Powering chatbot logic Backends • Apps and services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit IT automation • Policy engines • Extending AWS services • Infrastructure management
  6. 6. Deep Dive/Components
  7. 7. Using AWS Lambda Bring your own code • Node.js, Java, Python, C#, Go • Bring your own libraries (even native ones) Simple resource model • Select power rating from 128 MB to 3 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
  8. 8. Using AWS Lambda Authoring functions • WYSIWYG editor or upload packaged .zip • AWS Cloud9 IDE • Third-party plugins (Eclipse, Visual Studio) Monitoring and logging • Metrics for requests, errors, and throttles • Built-in logs to Amazon CloudWatch Logs • Distributed tracing with AWS X-Ray 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
  9. 9. Amazon S3 Amazon DynamoDB Amazon Kinesis AWS CloudFormation AWS CloudTrail Amazon CloudWatch Amazon Cognito Amazon SNSAmazon SES Cron events Data stores Endpoints Configuration repositories Event/message services Example Event Sources That Trigger AWS Lambda … and more on the way. AWS CodeCommit Amazon API Gateway Amazon Alexa AWS IoT AWS Step Functions
  10. 10. Lambda Execution Model Synchronous (push) Asynchronous (event) Stream-based Amazon API Gateway AWS Lambda function Amazon DynamoDBAmazon SNS /order AWS Lambda function Amazon S3 reqs Amazon Kinesis changes AWS Lambda service function
  11. 11. Amazon API Gateway Create a unified API frontend for multiple microservices Authenticate and authorize requests to a backend DDoS protection and throttling for your backend Throttle, meter, and monetize API usage by third-party developers
  12. 12. API Gateway Integrations Internet Mobile apps Websites Services AWS Lambda functions AWS API Gateway Cache Endpoints on Amazon EC2 All publicly accessible endpoints Amazon CloudWatch Monitoring Amazon CloudFront Any other AWS service Your VPC Endpoints in your VPC Regional API endpoints
  13. 13. Amazon API Gateway Lambda Proxy Integration { "resource": "Resource path", "path": "Path parameter", "httpMethod": "Incoming request's method name", "headers": {Incoming request headers}, "queryStringParameters": {Query string parameters}, "pathParameters":{Path parameters}, "stageVariables": {Applicable stage variables}, "requestContext": {Request context, including authorizer-returned key-value pairs}, "body": "...", "isBase64Encoded": true|false } { "statusCode": httpStatusCode, "headers": { "headerName": "headerValue", ... }, "body": "...”, "isBase64Encoded": true|false } Input Format of a Lambda Function for Proxy Integration Output Format of a Lambda Function for Proxy Integration
  14. 14. AWS Serverless Application Model (SAM) Simplified template driven deployment model for serverless applications Supported serverless resource types: functions, APIs, and tables Supports anything AWS CloudFormation supports Open specification (Apache 2.0) https://github.com/awslabs/serverless-application-model
  15. 15. SAM Template Tells AWS CloudFormation this is a SAM template it needs to transform Creates a Lambda function with the referenced managed IAM policy, runtime, code at the referenced zip location, and handler as defined. Also creates an API Gateway and takes care of all mapping/permissions necessary Creates a DynamoDB table with five read & write units AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip Handler: index.gethtml Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable
  16. 16. SAM Template Properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable Handler: index.js Runtime: nodejs4.3 CodeUri: 's3://my-code-bucket/my-function.zip' Description: Creates thumbnails of uploaded images MemorySize: 1024 Timeout: 15 Policies: AmazonS3FullAccess Environment: Variables: TABLE_NAME: my-table Events: PhotoUpload: Type: S3 Properties: Bucket: my-photo-bucket Tracing: Active|PassThrough Tags: AppNameTag: ThumbnailApp DepartmentNameTag: ThumbnailDepartmentFrom SAM Version 2016-10-31
  17. 17. SAM Template Properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable StageName: prod DefinitionUri: swagger.yml CacheClusterEnabled: true CacheClusterSize: 28.4 Variables: VarName: VarValue From SAM Version 2016-10-31
  18. 18. SAM Template Properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable PrimaryKey: Name: id Type: String ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 From SAM Version 2016-10-31
  19. 19. SAM Commands – Package & Deploy Package • Creates a deployment package (.zip file) • Uploads deployment package to an Amazon S3 bucket • Adds a CodeUri property with Amazon S3 URI Deploy • Calls AWS CloudFormation ‘CreateChangeSet’ API • Calls AWS CloudFormation ‘ExecuteChangeSet’ API
  20. 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS SAM CLI (formerly SAM Local) CLI tool for local development and testing of serverless apps Works with Lambda functions and “proxy-style” APIs Response object and function logs available on your local machine Uses open source docker-lambda images to mimic Lambda’s execution environment: • Emulates timeout, memory limits, runtimes https://github.com/awslabs/aws-sam-cli
  21. 21. AWS Serverless Application Repository • Search and browse ready-made apps and samples • Customize open-source apps to get started quickly • Share apps privately or publically • Monetize APIs using the AWS Marketplace • All apps powered by AWS SAM
  22. 22. Customers Love AWS Lambda
  23. 23. Case Study
  24. 24. Fannie Mae Serverless Financial Modeling Financial Modeling is a Monte-Carlo simulation process to project future cash flows, which is used for managing the mortgage risk on daily basis: • Underwriting and valuation • Risk management • Financial reporting • Loss mitigation and loan removal • ~10 Quadrillion (10#10$%) of cash flow projections each month in hundreds of economic scenarios. • One simulation run of ~ 20 million mortgages takes 1.4 hours, >4 times faster than the existing process. Federal National Mortgage Association Case Study
  25. 25. Martin Buberl VP of Engineering at Trustpilot AWS User Group Leader @martinbuberl
  26. 26. Open Review Platform Startup / Raised $140M 650 Trusties in 7 offices That’s what we call somebody working here
  27. 27. Event-driven microservices REST APIs Cloud-native Architecture 550 Services
  28. 28. If serverless is not available or practical, containers are recommended. Virtual servers (EC2) are considered legacy and should be avoided. Serverless First Engineering Principle
  29. 29. # of service - by type ‘16 to ‘18 Serverless First EC2 ECS Lambda
  30. 30. 12 / 2016 180 EC2s 80 Containers 40 Lambda functions 05 / 2018 90 EC2s 260 Containers 200 Lambda functions -50% +330% +500%
  31. 31. What are all those Lambda functions doing?
  32. 32. ... integrating with API Gateway ... subscribing to Amazon SNS Lambda functions We’ll look into this
  33. 33. Pub/Sub Messaging with Amazon SNS
  34. 34. “Traditional” Auto Scaling on Amazon SQS queues
  35. 35. Serverless with AWS Lambda
  36. 36. Are Lambda functions cheaper?
  37. 37. !==
  38. 38. For us™ they are 10x cheaper I would use them even if they would be more expensive Lambda functionsDisclaimer
  39. 39. Thank you - @martinbuberl
  40. 40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. version NEW How do we deploy a new version of our code? version OLD ?
  41. 41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless Deployment Pattern Considerations Minimizing Impact to consumers Rollback technique Execution model factors Deployment Speed
  42. 42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Alias Traffic Shifting myLambdaFunction 1 2 3 = prod My First API Stage variable = lambdaAlias Prod lambdaAlias = prod aws lambda update-alias --name prod --function-name myLambdaFunction --function-version 3 --routing-config ''
  43. 43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Alias Traffic Shifting myLambdaFunction 1 2 3 = prod 4 5 6 = prod 5% My First API Stage variable = lambdaAlias Prod lambdaAlias = prod aws lambda update-alias --name prod --function-name myLambdaFunction --routing-config AdditionalVersionWeights={”6"=0.05}
  44. 44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM Globals + Safe Deployments Globals: Function: Runtime: nodejs4.3 AutoPublishAlias: !Ref ENVIRONMENT MyLambdaFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler DeploymentPreference: Type: Linear10PercentEvery10Minutes Alarms: # A list of alarms that you want to monitor - !Ref AliasErrorMetricGreaterThanZeroAlarm - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm Hooks: # Validation Lambda functions that are run before & after traffic shifting PreTraffic: !Ref PreTrafficLambdaFunction PostTraffic: !Ref PostTrafficLambdaFunction NEW!
  45. 45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Alias Traffic Shifting & AWS SAM AutoPublishAlias By adding this property and specifying an alias name, AWS SAM will do the following: • Detect when new code is being deployed based on changes to the Lambda function's Amazon S3 URI. • Create and publish an updated version of that function with the latest code. • Create an alias with a name you provide (unless an alias already exists) and points to the updated version of the Lambda function. Deployment Preference Type Canary10Percent5Minutes Canary10Percent10Minutes Canary10Percent15Minutes Canary10Percent30Minutes Linear10PercentEvery1Minutes Linear10PercentEvery2Minute Linear10PercentEvery3Minutes Linear10PercentEvery10Minutes AllAtOnce In SAM:
  46. 46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Alias Traffic Shifting & AWS SAM Alarms: # A list of alarms that you want to monitor - !Ref AliasErrorMetricGreaterThanZeroAlarm - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm Hooks: # Validation Lambda functions that are run before & after traffic shifting PreTraffic: !Ref PreTrafficLambdaFunction PostTraffic: !Ref PostTrafficLambdaFunction In SAM: Note: You can specify a maximum of 10 alarms
  47. 47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeDeploy + Lambda NEW!
  48. 48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway Canary Support Use canary release deployments to gradually roll out new APIs in Amazon API Gateway: • configure percent of traffic to go to a new stage deployment • can test stage settings and variables • API gateway will create additional Amazon CloudWatch Logs group and CloudWatch metrics for the requests handled by the canary deployment API • To rollback: delete the deployment or set percent of traffic to 0 NEW!
  49. 49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Continuous delivery service for fast and reliable application updates Model and visualize your software release process Builds, tests, and deploys your code every time there is a code change Integrates with third-party tools and AWS AWS CodePipeline
  50. 50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. An example minimal Developer’s pipeline: MyBranch-Source Source CodeCommit MyApplication Build test-build-source CodeBuild MyDev-Deploy create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Run-stubs AWS Lambda This pipeline: • Three Stages • Builds code artifact • One Development environment • Uses SAM/CloudFormation to deploy artifact and other AWS resources • Has Lambda custom actions for running my own testing functions
  51. 51. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. An example minimal production pipeline: This pipeline: • Five Stages • Builds code artifact • Three deployed to “Environments” • Uses SAM/CloudFormation to deploy artifact and other AWS resources • Has Lambda custom actions for running my own testing functions • Integrates with a 3rd party tool/service • Has a manual approval before deploying to production Source Source CodeCommit MyApplication Build test-build-source CodeBuild Deploy Testing create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Run-stubs AWS Lambda Deploy Staging create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Run-API-test Runscope QA-Sign-off Manual Approval Review Deploy Prod create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Post-Deploy-Slack AWS Lambda
  52. 52. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. https://sbd.danilop.net O pen Source Serverless by Design
  53. 53. Thank you! @danilop @martinbuberl

×