Serverless Architecture Hochskalierbare Anwendungen ohne Server Sascha Möllering, Solutions Architect
Agenda Serverless Architecture AWS Lambda Amazon API Gateway Amazon DynamoDB Amazon S3 Serverless Framework Q&A
Background How serverless architecture patterns with AWS Lambda are the next evolution of application design
The Monolithic Architecture
The Service-Oriented Architecture Data Tier Presentation Tier Logic Tier
The Microservices Architecture
Why serverless architectures? No servers to manage and scale Run at scale Respond quickly to events Only pay for compute time that you use Developer productivity
Serverless microservice architecture Amazon S3 Static Content Web client End user Amazon DynamoDB Messages Data Store Amazon API Gateway REST Interface AWS Lambda Backend Logic
AWS Lambda
AWS compute offerings Amazon EC2 Resizable virtual servers in the cloud Amazon ECS Container management service for running Docker on EC2 AWS Lambda Serverless compute, run code in response to events
Benefits of using Lambda No Servers to Manage Continuous Scaling Subsecond Metering Lambda automatically runs your code without requiring you to provision or manage servers. Just write the code and upload it to Lambda. Lambda automatically scales your application by running code in response to each trigger. Your code runs in parallel and processes each trigger individually, scaling precisely with the size of the workload. With Lambda, you are charged for every 100 ms your code executes and the number of times your code is triggered. You don t pay anything when your code isn t running.
AWS Lambda How it works Bring your own code Node.js, Java, Python Java = Any JVM based language such as Scala, Clojure, etc. Bring your own libraries Simple resource model Select memory from 128MB to 1.5GB in 64MB steps CPU & Network allocated proportionately to RAM Reports actual usage Flexible invocation paths Event or RequestResponse invoke options Existing integrations with various AWS services Fine grained permissions Uses IAM role for Lambda execution permissions Uses Resource policy for AWS event sources
AWS Lambda Use Cases Data Processing Execute code in response to changes in data, shifts in system state, or actions by users Backends Execute backend logic to handle requests for web, mobile, IoT, and 3 rd APIs Control Systems Customize responses and response workflows to state and data changes within AWS
Amazon API Gateway
Benefits of Amazon API Gateway Create a unified API front end for multiple microservices DDoS protection and throttling for back-end systems Authenticate and authorize requests
Benefits of Amazon API Gateway Managed cache to store API responses Reduced latency and distributed denial of service (DDoS) protection through Amazon CloudFront SDK generation for ios, Android, and JavaScript Swagger support Request and response data transformation
An API call flow AWS Mobile apps API Gateway cache AWS Lambda functions Websites Internet API Gateway Endpoints on Amazon EC2/AWS Elastic Beanstalk Services Amazon CloudWatch monitoring Any other publicly accessible endpoint
Amazon DynamoDB
Fast, Consistent Performance Single-digit millisecond latency At any scale Data stored on Solid State Drives (SSDs) Automatic partitioning means no need for hotspot management
Highly Scalable Simply specify each table s read and write throughput capacity Increase and decrease capacity as needed No upper limit DynamoDB manages all the scaling behind the scenes
Flexible Key-value store model Each item in a DynamoDB table is a list of attributes (fields) and values Document store Place JSON-formatted data into DynamoDB items for robust, nested data structures No need for every item to have the same attributes Add attributes at will
Amazon DynamoDB is a schemaless database table items Attributes (name/value pairs or JSON documents)
Amazon S3
Amazon S3 - Features Secure Data transfer over SSL, bucket policies to manage object permissions Available Designed for up to 99.99% availability Durable Durability of 99.999999999% of objects
Amazon S3 - Website Hosting Host static websites on Amazon S3 HTML + JS + CSS Use JS to communicate with Amazon API Gateway
Amazon S3 - Website Hosting
Serverless Framework Open-source application framework Build serverless architectures Manages your code as well as your infrastructure (AWS CloudFormation) Supports multiple languages (Node.js, Python, Java, Scala)
Serverless Framework Functions: AWS Lambda function, independent unit of deployment Events: Anything that triggers an AWS Lambda Function Resources: AWS infrastructure components which your Functions use Service: Framework's unit of organization (project file) Plugin: overwrite or extend the functionality of the Framework
Serverless Framework serverless.yml: Contains Resources src/*: Contains Functions package.json: Dependencies event.json: Test event (local testing)
Demo
Summary Serverless Architecture is cost effective and highly scalable Focus on business success Increased developer productivity
A Call to Action
Go build something! Amazon API Gateway AWS Lambda Amazon DynamoDB
Everything and Anything Startups Need to Get Started on AWS aws.amazon.com/de/activate/