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.

CMP211_Getting Started with Serverless Architectures

869 views

Published on

"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 Step Functions).

We will discuss how to use serverless architectures for a variety of use cases including data processing, website backends, serverless applications, and “operational glue.” You will also get practical tips and tricks, best practices, and architecture patterns that you can take back and implement immediately."

  • Be the first to comment

CMP211_Getting Started with Serverless Architectures

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Getting Started with Serverless Architectures C h r i s M u n n s – S e r v e r l e s s S e n i o r D e v e l o p e r A d v o c a t e – A W S N i c k y J o s h i – D i r e c t o r S o f t w a r e E n g i n e e r i n g – C a p i t a l O n e N o v e m b e r 2 8 , 2 0 1 7 C M P 2 1 1
  2. 2. About me Chris Munns—munns@amazon.com, @chrismunns • Senior Developer Advocate–Serverless • New Yorker • Previously: • AWS Business Development Manager—DevOps, July 2015–February 2017 • AWS Solutions Architect, November 2011–December 2014 • Formerly on operations teams @Etsy and @Meetup • Little time at a hedge fund, Xerox, and a few other startups • Rochester Institute of Technology: Applied Networking and Systems Administration, ’05 • Internet infrastructure geek © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  3. 3. https://secure.flickr.com/photos/mgifford/4525333972 Why are we here today?
  4. 4. No servers to provision or manage Scales with usage Never pay for idle Availability and fault-tolerance built in Serverless means… © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  5. 5. SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state EVENT SOURCE FUNCTION Node.js Python Java C# Serverless applications © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  6. 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CUSTOMERS LOVE SERVERLESS
  7. 7. Common serverless 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 and services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit IT automation • Policy engines • Extending AWS services • Infrastructure management © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  8. 8. Event-Driven Compute Functions as a Service Serverless FaaS © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  9. 9. 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 © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  10. 10. 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 © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  11. 11. Fine-grained pricing Buy compute time in 100-ms increments Low request charge No hourly, daily, or monthly minimums No per-device fees Never pay for idle Free Tier 1 M requests and 400,000 GB-s of compute Every month, every customer © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  12. 12. 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 © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  13. 13. Amazon S3 Amazon DynamoDB Amazon Kinesis AWS CloudFormation AWS CloudTrail Amazon CloudWatch Amazon Cognito Amazon SNSAmazon SES Cron events DATA STORES ENDPOINTS DEVELOPMENT AND MANAGEMENT TOOLS EVENT/MESSAGE SERVICES Event sources that trigger AWS Lambda …and more! AWS CodeCommit Amazon API Gateway Amazon Alexa AWS IoT AWS Step Functions © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  14. 14. Lambda permissions model Fine-grained security controls for both execution and invocation Execution policies: • Define what AWS resources/API calls this function can access via IAM • Used in streaming invocations • For example, “Lambda function A can read from DynamoDB table users” Function policies: • Used for sync and async invocations • For example, “Actions on bucket X can invoke Lambda function Z” • Resource policies allow for cross-account access © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  15. 15. Amazon API Gateway Internet Mobile Apps Websites Services AWS Lambda functions AWS All publicly accessible endpoints Amazon CloudWatch Monitoring Amazon CloudFront Any other AWS service Endpoints on Amazon EC2 AWS Step Functions © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  16. 16. Create a unified API front end 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 Amazon API Gateway © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  17. 17. AWS Step Functions “Serverless” workflow management with zero administration: • Makes it easy to coordinate the components of distributed applications and microservices using visual workflows • Automatically triggers and tracks each step, and retries when there are errors, so your application executes in order and as expected • Logs the state of each step, so when things do go wrong, you can diagnose and debug problems quickly Task Choice Failure capture Parallel Tasks © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  18. 18. Service for building conversational interfaces into any application using voice and text Automatic speech recognition (ASR) for converting speech to text Natural language understanding (NLU) to recognize the intent of messages Powered by the same deep-learning technology as Amazon Alexa Fully managed service Amazon Lex © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  19. 19. “Can I go ahead with the booking?” “Book a hotel” “Book a Hotel in NYC” Automatic Speech Recognition Hotel Booking New York City Natural Language Understanding Intent/Slot Model UtterancesHotel Booking City New York City Check In Nov 30th Check Out Dec 2nd “Your hotel is booked for Nov 30th” Amazon Polly Confirmation: “Your hotel is booked for Nov 30th” Book Hotel NYC a in
  20. 20. Amazon Kinesis AWS Lambda 1 Amazon CloudWatch Amazon DynamoDB AWS Lambda 2 Amazon S3 Real-time data processing: 1. Real-time event data sent to Amazon Kinesis allows multiple AWS Lambda functions to process the same events 2. In AWS Lambda, Function 1 processes and aggregates data from incoming events, then stores result data in Amazon DynamoDB 3. Lambda Function 1 also sends values to Amazon CloudWatch for simple monitoring of metrics 4. In AWS Lambda function, Function 2 does data manipulation of incoming events and stores results in Amazon S3 https://s3.amazonaws.com/awslambda-reference-architectures/stream-processing/lambda-refarch-streamprocessing.pdf Lambda + Kinesis
  21. 21. Bustle.com Bustle.com is a news, entertainment, lifestyle, and fashion website catering to women: • 52 million monthly users • 100 million events daily • 84% cost savings • 0 servers • 0 operating system patches • Automatic scaling https://aws.amazon.com/solutions/case-studies/bustle/© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  22. 22. Amazon API Gateway AWS Lambda Amazon Kinesis AWS Lambda Redis Amazon Mobile Analytics Amazon CloudWatch Amazon Elasticsearch Service Amazon S3 Amazon RedshiftAmazon QuickSightEngineering Marketing & Operations Design Bustle.com users Bustle.com event-stream processing
  23. 23. Serverless distributed computing: PyWren PyWren prototype developed at University of California, Berkeley Uses Python with AWS Lambda stateless functions for large-scale data analytics Achieved @ 30-40 MB/s write and read performance per core to Amazon S3 object store Scaled to 60-80 GB/s across 2,800 simultaneous functions
  24. 24. Square Enix Makers of Dragon Quest games: • Lambda processes 200-300 images uploaded per minute • Peak processing of 6,000 images per minute • Reduced image time from hours to only 10+ seconds at 1/20 the cost of their previous solution https://aws.amazon.com/solutions/case-studies/square-enix/© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  25. 25. Home24 coordinating daily imports of marketing data European market leader in online shopping for home and living products, operating in eight countries and two continents Built a reliable, long-running serverless application to coordinate the daily import of gigabytes of social media data from 20+ sources for use in business analytics © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  26. 26. How Home24 lowered costs by 99% Home24 sequenced a varying number of Lambda functions with AWS Step Functions to download and refine files from multiple sources • Cost savings: Saved 99% with AWS Step Functions as opposed to their previous SaaS solution • Productivity and agility: Engineers can easily coordinate various microservices to build ELT pipelines • Increased resilience: Automatic retries when service APIs are unavailable
  27. 27. Build PCI- and HIPAA-compliant serverless applications! Serverless platform services that can be used in both: AWS Lambda Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Kinesis Streams Amazon Cognito Amazon API Gateway Amazon SNS © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  28. 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Capital One Auto— Journey to Serverless
  29. 29. Capital One • Top 10 US bank • Al exa Websi te Ranki ng says capi tal one.com traffi c i s “ 81st i n US Web Si tes” • Auto fi nanci ng — one mi l l i on hi ts/month
  30. 30. Migration journey timeline
  31. 31. Migration requirements • Full functionality and more • Secure—yes, we actually are a financial institution • Resilient (active/active) • Responsive—front-facing marketing home page, so initial load time is critical • SEO-friendly • Continuous deployments—changes on demand • Low-maintenance—it just needs to run • Use existing tools and processes in the enterprise—don’t reinvent the wheel • Logging • Monitoring • Deployments
  32. 32. The painful old days • H o s t e d i n o n - p r e m i s e s d a t a c e n t e r • E n t e r p r i s e - w i d e c o m m o n d e p l o y m e n t s • O n e c a l e n d a r — f e a t u r e s p l a n n e d m o n t h s i n a d v a n c e • T i g h t c o u p l i n g b e t w e e n c o m p o n e n t s
  33. 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless migration—I Move to AWS Serverless content strategy
  34. 34. App architecture—content Amazon Route 53 Amazon S3 Amazon S3 East Region West Region Amazon CloudFront Amazon CloudFront
  35. 35. Amazon Route 53 Rest APIs EC2 EC2 EC2 EC2 WAF App AZ1 AZ2 AZ3 East EC2 EC2 EC2 EC2 WAF App AZ1 AZ2 AZ3 West App architecture—APIs
  36. 36. CI/CD for content • A p p t e m p l a t e s i n G i t H u b • C o n t e n t i n C M S h o s t e d s e r v i c e • P r e - r e n d e r a n g u l a r c o n t e n t , S E O - f r i e n d l y • U s e A W S C L I t o p u s h c o n t e n t t o A m a z o n S 3 b u c k e t f o r w e b h o s t i n g Content Management System AWS CLI Amazon EC2 Build Server Content S3 Bucket
  37. 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless migration—II Lambda-based APIs CI/CD processes
  38. 38. Move to serverless APIs Amazon Route 53 Rest APIs CapOne Enterprise Gateway Lambda Fn Amazon CloudWatch Lambda Fn East CapOne Enterprise Gateway Lambda Fn Amazon CloudWatch Lambda Fn West
  39. 39. CI/CD—Lambda functions AWS CLI Deployment S3 Bucket Lambda Create Lambda Update Lamba Fn • L a m b d a c o d e i n G i t H u b • J e n k i n s - t r i g g e r e d b u i l d • U s e s A W S C L I • D e p l o y i n A m a z o n S 3 b u c k e t • C r e a t e / u p d a t e L a m b d a f u n c t i o n • O t h e r o p t i o n s : • S A M • S e r v e r l e s s f r a m e w o r k
  40. 40. Benefits of serverless • Very simple architecture • Runs itself, less monitoring • Scales itself, no work on auto scaling needed • No worries on AMI rehydration, which keeps compliance and operations happy • Cost savings: • Conservative savings to tune of $50K/year • Amazon S3 web hosting eliminated any Amazon EC2 needs for website hosting • Able to eliminate 20 Amazon EC2 instances, CLBs, and Amazon EBS volumes from API architecture • Countless hours saved on operations of application
  41. 41. Lessons learned • Migration can be a journey, so plan accordingly • Step-by-step progress is recommended • Start small • Serverless architectures are flexible and fungible • No one size fits all • Reuse tools and processes in the organization • Get stakeholder buy-in early
  42. 42. FIN, ACK Serverless: • No servers to manage • No cost for idle • Automatic scaling • High availability Use cases: • Web applications • Backends • Data processing • Chatbots • Amazon Alexa • IT automation Integrated across AWS: • Amazon API Gateway • AWS Step Functions • Amazon S3 • Amazon Kinesis • Amazon DynamoDB • Amazon SNS • Amazon Cognito • AWS CloudFormation • AWS CodePipeline • Amazon CloudWatch • AWS IoT • Many more! © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  43. 43. aws.amazon.com/serverless
  44. 44. Chris Munns munns@amazon.com @chrismunnshttps://www.flickr.com/photos/theredproject/3302110152/
  45. 45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you! R e m e m b e r t o r e v i e w t h i s s e s s i o n ! C M P 2 1 1

×