Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started with Serverless Architectures

Getting Started with Serverless Architectures

Serverless architectures let you build and deploy applications and services with infrastructure resources that require zero administration. In the past, you had to provision and scale servers to run your application code, install and operate distributed databases, and build and run custom software to handle API requests. Now, AWS provides a stack of scalable, fully-managed services that eliminates these operational complexities. In this session, you will learn about serverless architectures, their benefits, and the basics of the AWS’s serverless stack (e.g., AWS Lambda, Amazon API Gateway, and AWS AppSync, etc).

Rohini Gaonkar

August 07, 2020
Tweet

More Decks by Rohini Gaonkar

Other Decks in Technology

Transcript

  1. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    Serverless Architectures Rohini Gaonkar Sr. Developer Advocate, India, AISPL (AWS India) @rohini_gaonkar @rohinigaonkar 7th August 2020
  2. © 2020, Amazon Web Services, Inc. or its Affiliates. Hello

    World..! q Born in Cloud! q With AWS for 6+ years q Started as Cloud Support Engineer, Cape Town, South Africa q Worked as AWS Solutions Architect in Singapore and in Mumbai, India q Now a Developer Advocate, India. @rohini_gaonkar @rohinigaonkar
  3. © 2020, Amazon Web Services, Inc. or its Affiliates. Computing

    evolution – A paradigm shift LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC PHYSICAL MACHINES Requires “guess” planning Lives for years on-premises Heavy investments (capex) Low innovation factor Deploy in months
  4. © 2020, Amazon Web Services, Inc. or its Affiliates. Computing

    evolution – A paradigm shift LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC VIRTUAL MACHINES Hardware independence Faster provisioning speed (minutes/hours) Trade capex for opex More scale Elastic resources Faster speed and agility Reduced maintenance
  5. © 2020, Amazon Web Services, Inc. or its Affiliates. Computing

    evolution – A paradigm shift LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC CONTAINERIZATION Platform independence Consistent runtime environment Higher resource utilization Easier and faster deployments Isolation and sandboxing Start speed (deploy in seconds)
  6. © 2020, Amazon Web Services, Inc. or its Affiliates. Computing

    evolution – A paradigm shift AWS Lambda AWS Fargate LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC Continuous scaling Fault tolerance built-in Pay for value Zero maintenance SERVERLESS
  7. © 2020, Amazon Web Services, Inc. or its Affiliates. Traditional

    three-tier application architecture Web servers Presentation layers Application servers Business logic Database servers Data layer
  8. © 2020, Amazon Web Services, Inc. or its Affiliates. A

    modern three-tier application architecture Presentation Business logic Data Queues/messages Events Events APIs
  9. © 2020, Amazon Web Services, Inc. or its Affiliates. Technology

    decisions drive your business strategy Modular services As managed as possible Automated & standardized Everyone’s responsibility Purpose built Architectural patterns 1 Operational model 2 Software delivery 3 Management & Governance 4 Data management 5
  10. © 2020, Amazon Web Services, Inc. or its Affiliates. Integration

    and communication Events are the connective tissue of modern applications APIs are the front door of microservices
  11. © 2020, Amazon Web Services, Inc. or its Affiliates. What

    is serverless? No infrastructure management Automatic scaling Pay for value Highly available and secure
  12. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Fargate API Gateway Amazon SNS Amazon SQS AWS Step Functions Compute Data stores Integration Aurora Serverless Amazon S3 DynamoDB AWS AppSync Amazon EventBridge https://aws.amazon.com/serverless/
  13. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Fargate API Gateway Amazon SNS Amazon SQS AWS Step Functions Compute Data stores Integration Aurora Serverless Amazon S3 DynamoDB AWS AppSync Amazon EventBridge
  14. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    operational responsibility models Compute Virtual machine Amazon EC2 AWS Elastic Beanstalk Lambda Fargate Databases MySQL MySQL on Amazon EC2 Amazon RDS for MySQL Amazon RDS Amazon Aurora DynamoDB Storage Storage S3 Messaging ESBs Amazon MQ Amazon Kinesis EventBridge/SQS/SNS Analytics Hadoop Hadoop on EC2 Amazon EMR Amazon Elasticsearch Service Amazon Athena On-premises Cloud Less More
  15. © 2020, Amazon Web Services, Inc. or its Affiliates. Comparison

    of operational responsibility AWS Lambda Serverless functions AWS Fargate Serverless containers Amazon ECS/Amazon EKS Container-management as a service Amazon EC2 Infrastructure-as-a-Service More opinionated Less opinionated AWS manages Customer manages • Data source integrations • Physical hardware, software, networking, and facilities • Provisioning • Application code • Container orchestration, provisioning • Cluster scaling • Physical hardware, host OS/kernel, networking, and facilities • Application code • Data source integrations • Security config and updates, network config, management tasks • Container orchestration control plane • Physical hardware software, networking, and facilities • Application code • Data source integrations • Work clusters • Security config and updates, network config, firewall, management tasks • Physical hardware software, networking, and facilities • Application code • Data source integrations • Scaling • Security config and updates, network config, management tasks • Provisioning, managing scaling and patching of servers
  16. © 2020, Amazon Web Services, Inc. or its Affiliates. Web

    applications • Static websites • Complex web apps • Packages for Flask and Express Data processing • Real-time • MapReduce • Batch 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 Common serverless use cases
  17. © 2020, Amazon Web Services, Inc. or its Affiliates. Customers

    love serverless https://aws.amazon.com/serverless/
  18. © 2020, Amazon Web Services, Inc. or its Affiliates. Serverless

    compute engine for containers Long-running Bring existing code Fully managed orchestration Fargate Let’s focus on compute for now Serverless event-driven code execution Short-lived All language runtimes Data-source integrations Lambda
  19. © 2020, Amazon Web Services, Inc. or its Affiliates. Serverless

    compute engine for containers Long-running Bring existing code Fully managed orchestration Fargate Let’s focus on compute for now Serverless event-driven code execution Short-lived All language runtimes Data-source integrations Lambda
  20. © 2020, Amazon Web Services, Inc. or its Affiliates. Making

    development easier with Lambda Accessible for all developers Enable new application patterns Greater productivity Support for all runtimes with Lambda Layers and Runtime API ISO, PCI, HIPAA, SOC, GDPR, and FedRamp compliances 15-minute functions Amazon SQS for Lambda Automatic load balancing for Lambda Support for Kinesis Data Streams Enhanced Fan-Out and HTTP/2 Toolkits for popular integrated development environments (IDEs): VSCode, IntelliJ, and PyCharm Simplified deployment with nested apps Trillions of executions every month for hundreds of thousands of active customers
  21. © 2020, Amazon Web Services, Inc. or its Affiliates. Typical

    Serverless applications Event source Function Services Changes in data state Requests to endpoints Changes in Resource state Node.js Python Java C# Go Ruby Runtime API
  22. © 2020, Amazon Web Services, Inc. or its Affiliates. Amazon

    S3 Amazon SNS Amazon SES Cron events DATA STORES ENDPOINTS DEVELOPMENT AND MANAGEMENT TOOLS EVENT/MESSAGE SERVICES Event sources that trigger AWS Lambda …and more! Amazon API Gateway Amazon Alexa AWS IoT AWS Step Functions Amazon DynamoDB Amazon Kinesis Amazon Cognito AWS CloudFormation AWS CloudTrail AWS CodeCommit Amazon CloudWatch
  23. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Execution Model Synchronous (push) Asynchronous (event) Stream-based (poll) Amazon API Gateway AWS Lambda function Amazon DynamoDB Amazon SNS /order AWS Lambda function Amazon S3 reqs Amazon Kinesis changes AWS Lambda service function
  24. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Execution Model Synchronous (push) Asynchronous (event) Stream-based (poll) Amazon API Gateway AWS Lambda function Amazon DynamoDB Amazon SNS /order AWS Lambda function Amazon S3 reqs Amazon Kinesis changes AWS Lambda service function
  25. © 2020, Amazon Web Services, Inc. or its Affiliates. 'use

    strict' exports.handler = function (event, context, callback) { console.log(“Event:”, JSON.stringify(event)) callback(null, ”Hello World!") } { “Records”:[ “s3”: { “object”:” { … } } ] } JSON Context Basic Sync Function Code © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  26. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Execution Model Synchronous (push) Asynchronous (event) Stream-based (poll) Amazon API Gateway AWS Lambda function Amazon DynamoDB Amazon SNS /order AWS Lambda function Amazon S3 reqs Amazon Kinesis changes AWS Lambda service function
  27. © 2020, Amazon Web Services, Inc. or its Affiliates. 'use

    strict' exports.handler = async function (event, context) { console.log(“Event:”, JSON.stringify(event)) return context.logStreamName } { “Records”:[ “s3”: { “object”:” { … } } ] } JSON Context Basic Async Function Code © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  28. © 2020, Amazon Web Services, Inc. or its Affiliates. Event-driven

    architectures drive reliability and scalability Asynchronous Events Improve responsiveness and reduce dependencies Event Routers Abstract producers and consumers from each other Event Stores Buffer messages until services are available to process
  29. © 2020, Amazon Web Services, Inc. or its Affiliates. Event

    Targets AWS Lambda Amazon Kinesis Data Firehose Amazon SNS Additional Targets SaaS Event Sources SaaS Event Sources Event Routers Custom Event Bus SaaS Event Bus Default Event Bus AWS Service Event Sources Topics
  30. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Fargate API Gateway Amazon SNS Amazon SQS AWS Step Functions Compute Data stores Integration Aurora Serverless Amazon S3 DynamoDB AWS AppSync Amazon EventBridge
  31. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda

    Execution Model Synchronous (push) Asynchronous (event) Stream-based (poll) Amazon API Gateway AWS Lambda function Amazon DynamoDB Amazon SNS /order AWS Lambda function Amazon S3 reqs Amazon Kinesis changes AWS Lambda service function
  32. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    Step Functions “Serverless” workflow management
  33. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    Step Functions “Serverless” workflow management with zero administration: • Coordinates distributed applications using visual workflows • Automatically triggers, tracks, and logs each step • You can run your tasks in the AWS Cloud, on your servers, or on any system that has access to AWS.
  34. © 2020, Amazon Web Services, Inc. or its Affiliates. Amazon

    API Gateway Create RESTful APIs and WebSocket APIs
  35. © 2020, Amazon Web Services, Inc. or its Affiliates. 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
  36. © 2020, Amazon Web Services, Inc. or its Affiliates. Reference

    architecture for RESTful microservices AWS Lambda functions AWS API Gateway Amazon DynamoDB Tables API Clients
  37. © 2020, Amazon Web Services, Inc. or its Affiliates. Internet

    Mobile Apps Websites Services Amazon CloudFront Amazon CloudWatch Amazon API Gateway Amazon EC2 All publicly accessible endpoints AWS Lambda Other AWS services Amazon API Gateway Endpoints Your VPC Edge-optimized API endpoint APIGW Cache Region Endpoints in your VPC Private API endpoint Regional API endpoint
  38. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    AppSync Real-time, Offline and GraphQL
  39. © 2020, Amazon Web Services, Inc. or its Affiliates. •

    Open, declarative data-fetching specification • != Graph database • Use NoSQL, Relational, HTTP, etc. Traditional data-fetching GraphQL What is GraphQL? query GetUserInfo { User(id: ”737”) { name birthdate posts {likes} followers (last 10) {name} }} /users/<id> /users/<id>/posts /users/<id>/followers /users/<id>/posts/likes
  40. © 2020, Amazon Web Services, Inc. or its Affiliates. Architecture

    Diagram Internet Mobile Apps Websites Services AWS Lambda functions Amazon DynamoDB Amazon CloudWatch Monitoring AWS AppSync All publicly HTTP/S accessible endpoints Amazon Elasticsearch Amazon RDS Amazon EC2 Any other AWS service VPC
  41. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    AppSync Resolvers Lambda Function DynamoDB Table HTTP Endpoint Amazon Elasticsearch Data Sources Queries Mutations Types Subscriptions GraphQL Schema and objects Web App Mobile App Frontend How does AWS AppSync work?
  42. © 2020, Amazon Web Services, Inc. or its Affiliates. Queries

    query GetPost { getPost(id: ”1”) { id title } } mutation CreatePost { createPost(title: “TLV Summit”) { id title } } subscription OnCreatePost { onCreatePost { id title } } Mutations Subscriptions A query language for APIs…
  43. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    serverless storage and database options Object storage Durable and scalable Comprehensive security Query-in-place Amazon S3 Non-relational Performance at scale Fully managed Enterprise-ready Amazon DynamoDB Serverless Relational Fully managed High performance Cost effective Amazon Aurora
  44. © 2020, Amazon Web Services, Inc. or its Affiliates. Security

    and Identity • User pools for secure, managed user directories • Identity pools for federation and role-based access control Amazon Cognito • Fine-grained access control to AWS resources AWS Identity and Access Management
  45. © 2020, Amazon Web Services, Inc. or its Affiliates. Simple

    and Secure User Sign-Up, Sign-In, and Access Control Managed User Directory Federation AWS Credentials Standard Tokens JWT Advanced Security Features Hosted UI Amazon Cognito
  46. © 2020, Amazon Web Services, Inc. or its Affiliates. Logging

    and Monitoring AWS X-Ray Amazon CloudWatch
  47. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    Serverless Application Model (SAM) – Open source • AWS CloudFormation extension • Build, test, and debug locally via SAM CLI • Open-source framework • Search and deploy serverless apps on the AWS Serverless Application Repository https://aws.amazon.com/serverless/sam/
  48. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    SAM Template Tells AWS CloudFormation this is a SAM template it needs to “transform” Creates a AWS Lambda function with the referenced managed AWS IAM policy, runtime, code at the referenced zip location, and handler as defined. Also creates an Amazon API Gateway and takes care of all mapping/ permissions necessary Creates a Amazon DynamoDB table with 5 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: nodejs6.10 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable
  49. © 2020, Amazon Web Services, Inc. or its Affiliates. Demo

    Serverless Frontend Serverless Backend https://github.com/aws-samples/aws-serverless-workshop-innovator-island
  50. © 2020, Amazon Web Services, Inc. or its Affiliates. Integration

    and communication Events are the connective tissue of modern applications APIs are the front door of microservices
  51. © 2020, Amazon Web Services, Inc. or its Affiliates. Serverless

    Microservice Patterns for AWS https://www.jeremydaly.com/serverless-microservice-patterns-for-aws/ Circuit Breaker Aggregator Scalable Webhook Simple Web Service Continuous Stream
  52. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    Serverless https://aws.amazon.com/serverless/
  53. © 2020, Amazon Web Services, Inc. or its Affiliates. Well-Architected

    lens - Serverless Application Well-Architected Framework Pillars 1. Operational excellence, 2. Security, 3. Reliability, 4. Performance efficiency, 5. Cost optimization. https://d1.awsstatic.com/whitepapers/architecture/AWS-Serverless-Applications-Lens.pdf Whitepaper :
  54. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS

    Free tier https://aws.amazon.com/free/
  55. © 2020, Amazon Web Services, Inc. or its Affiliates. “Going

    serverless frees you to focus on activities that set your company apart, like product innovation” Werner Vogels, CTO, Amazon
  56. © 2020, Amazon Web Services, Inc. or its Affiliates. Go

    Build..! Rohini Gaonkar Sr. Developer Advocate, AWS @rohini_gaonkar @rohini-gaonkar