© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Randall Hunt, Technical Evangelist April 2017 Lambda Can Do That? Unexpected Places To Use AWS Lambda
Agenda What is AWS Lambda? What is a Serverless Application? What are some unexpected use cases of AWS Lambda? • Event Sources • Orchestration Tools • Third Party Libraries
What is AWS Lambda?
AWS compute offerings VM Task Function Service EC2 ECS Lambda H/W OS Runtime Unit of scale Level of abstraction
AWS compute offerings I want to configure servers, 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?
AWS Lambda: Run code in response to events FUNCTION SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state Node Python Java C# EVENT SOURCE
Using AWS Lambda Bring your own code • Node.js, Java, Python, C# • 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
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
What are serverless applications?
Servers How 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!!)
Operations and management Scaling Provisioning and utilization Availability and fault tolerance Owning servers means dealing with ...
Amazon API Gateway: Serverless APIs 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 Amazon API Gateway Any other AWS service
No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Benefits of Lambda and serverless compute
Common use cases Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit IT Automation • Policy engines • Extending AWS services • Infrastructure management
Unexpected Adventures in Lambda and AWS
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 What can we do with these? … and a few more with more on the way! AWS CodeCommit Amazon API Gateway Amazon Alexa AWS IoT AWS Step Functions
You can do anything.
When I need to iterate quickly • Focus on the business logic • Reuse don’t rewrite • Test quickly locally and remotely • Scale effortlessly
Focus On The Business Logic
Where am I? – Architecture Mother Lambda function Query Response Child Information
Grab the location import os import foursquare token = os.getenv('ACCESS_TOKEN') client = foursquare.Foursquare(access_token=token) def get_loc(): checkin = client.users.checkins(params={'limit': 1})['checkins']['items'][0] venue = checkin['venue'] return { 'name': venue['name'], # name 'loc': [venue['location']['lat'], venue['location']['lng']], 'ts': checkin['createdAt'] #when }
Handle The Event def lambda_handler(event, context): loc = get_loc() return loc
DEMO
Architecture
Other Ideas
Other Ideas • Alexa and HealthAI - @OliPicard • Parsing logs when logstash is too slow - @MartinJThwaites • Sandboxes for untrusted code - @dasniko • Processing DNA segments in parallel • Incident Management - @celiturgay • Cloudformation Custom Resources - @thelogicbox • ffmpeg on s3 upload
Lessons • Lambda can be invoked by **anything** or you can figure out a way to make it happen. • Don’t think about the code, think about the outcome and work backwards. • Iterate and test quickly with local code and fake events.
AWS Lambda 활용의 모든 것! - AWS Summit Seoul 2017

AWS Lambda 활용의 모든 것! - AWS Summit Seoul 2017

  • 1.
    © 2016, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Randall Hunt, Technical Evangelist April 2017 Lambda Can Do That? Unexpected Places To Use AWS Lambda
  • 2.
    Agenda What is AWSLambda? What is a Serverless Application? What are some unexpected use cases of AWS Lambda? • Event Sources • Orchestration Tools • Third Party Libraries
  • 3.
    What is AWSLambda?
  • 4.
    AWS compute offerings VMTask Function Service EC2 ECS Lambda H/W OS Runtime Unit of scale Level of abstraction
  • 5.
    AWS compute offerings Iwant to configure servers, 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?
  • 6.
    AWS Lambda: Runcode in response to events FUNCTION SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state Node Python Java C# EVENT SOURCE
  • 7.
    Using AWS Lambda Bringyour own code • Node.js, Java, Python, C# • 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
  • 8.
    Using AWS Lambda Authoringfunctions • 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
  • 9.
  • 10.
    Servers How will theapplication 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!!)
  • 11.
    Operations and managementScaling Provisioning and utilization Availability and fault tolerance Owning servers means dealing with ...
  • 12.
    Amazon API Gateway:Serverless APIs 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 Amazon API Gateway Any other AWS service
  • 13.
    No servers toprovision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Benefits of Lambda and serverless compute
  • 14.
    Common use cases Web Applications •Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit IT Automation • Policy engines • Extending AWS services • Infrastructure management
  • 15.
  • 16.
    Amazon S3 Amazon DynamoDB Amazon Kinesis AWS CloudFormation AWSCloudTrail Amazon CloudWatch Amazon Cognito Amazon SNSAmazon SES Cron events DATA STORES ENDPOINTS CONFIGURATION REPOSITORIES EVENT/MESSAGE SERVICES What can we do with these? … and a few more with more on the way! AWS CodeCommit Amazon API Gateway Amazon Alexa AWS IoT AWS Step Functions
  • 17.
    You can doanything.
  • 19.
    When I needto iterate quickly • Focus on the business logic • Reuse don’t rewrite • Test quickly locally and remotely • Scale effortlessly
  • 20.
    Focus On TheBusiness Logic
  • 21.
    Where am I?– Architecture Mother Lambda function Query Response Child Information
  • 22.
    Grab the location importos import foursquare token = os.getenv('ACCESS_TOKEN') client = foursquare.Foursquare(access_token=token) def get_loc(): checkin = client.users.checkins(params={'limit': 1})['checkins']['items'][0] venue = checkin['venue'] return { 'name': venue['name'], # name 'loc': [venue['location']['lat'], venue['location']['lng']], 'ts': checkin['createdAt'] #when }
  • 23.
    Handle The Event deflambda_handler(event, context): loc = get_loc() return loc
  • 24.
  • 25.
  • 26.
  • 27.
    Other Ideas • Alexaand HealthAI - @OliPicard • Parsing logs when logstash is too slow - @MartinJThwaites • Sandboxes for untrusted code - @dasniko • Processing DNA segments in parallel • Incident Management - @celiturgay • Cloudformation Custom Resources - @thelogicbox • ffmpeg on s3 upload
  • 28.
    Lessons • Lambda canbe invoked by **anything** or you can figure out a way to make it happen. • Don’t think about the code, think about the outcome and work backwards. • Iterate and test quickly with local code and fake events.