SERVERLESS ARCHITECTURES (WITH AWS INFRASTRUCTURE) Niko Köbler So�ware-Architect, Developer & Trainer niko@n-k.de www.n-k.de @dasniko | |
@dasniko
DISCLAIMER This is NO silver bullet, no standard, but opinionated!
SERVERLESS
SERVER WHAT ?
This is what actually mean... serverless
Serverless is about the management of servers. Build and run applications without thinking about servers.
EVOLUTION OF COMPUTING Physical Servers in datacenters Virtual Machines in datacenters Virtual Machines in Cloud Containers on Virtual Machines Serverless as the unit of compute
SERVERLESS COMPUTE MANIFESTO Functions are the unit of deployment and scaling. No machines, VMs, or containers visible in the programming model. Permanent storage lives elsewhere. Scales per request; Users cannot over- or under-provision capacity. Never pay for idle (no cold servers/containers or their costs). Implicitly fault-tolerant because functions can run anywhere. BYOC - Bring Your Own Code. Metrics and logging are a universal right.
Source: various AWS presentations
PAAS ? Unit of deployment and scale!
PaaS vs. FaaS is as DevOps vs. NoOps
AWS LAMBDA
AWS LAMBDA Event Driven JVM-based languages (Java 8), JavaScript (Node.js), Python, C#, (more to come) Versions, Encrypted Environment Variables, Step Functions Pay as you use - in 100ms blocks (e.g. 100ms w/ 128MB memory = USD 0.000000208)
AWS LAMBDA NODE EXAMPLE exports.handler = (event, context) => { console.log('Received event:', JSON.stringify(event)); }
AWS LAMBDA JAVA EXAMPLE public class ImageProcessor implements RequestHandler<S3Event, Void> { @Override public Void handleRequest(S3Event s3Event, Context context) { // get the S3 event data from the event request S3EventNotification.S3EventNotificationRecord record = s3Event.getRecords().get(0); // your code goes here... // return an object with specified type (see class generics) return null; } }
AWS LAMBDA EVENTS S3 Code Commit DynamoDB Cognito SNS Cloud Watch Cloud Formation SES Config Echo / Alexa Kinesis API Gateway AWS IoT Cron (no complete list)
API GATEWAY
API GATEWAY "Reverse Proxy" hides possible multiple service calls (aka "service composition", ESB?) distributes requests to proper service instances "Mock" services Caching, Throttling, DDoS attack protection, etc.
NETFLIX API GATEWAY
API GATEWAY "Reverse Proxy" hides possible multiple service calls (aka "service composition", ESB?) distributes requests to proper service instances "Mock" services Caching, Throttling, DDoS attack protection, etc.
API GATEWAY AUTHENTICATION / AUTHORIZATION AWS Cognito / STS Custom Authorizer (Lambda Function, returning IAM policies)
API GATEWAY AUTHORIZATION
API GATEWAY
DYNAMODB
DYNAMO DB Fully Managed NoSQL Data Store Schemaless Data Model Seamless Scalabiltiy, "no limits" Pay by Read-/Write-Capacity-Units
Example USE CASES
SERVERLESS WEB ARCHITECTURE
SERVERLESS WEB ARCHITECTURE
API Gateway with SNS , Push and SQS
ALEXA SKILLS BOTS (CHAT/VOICE)
TESTING
TESTING UNIT TESTS Functions are easy to test, stateless and little to no dependencies
TESTING INTEGRATION TESTS Environment, Infrastructure max. 1024 of running processes/threads max. 100 concurrent Lambdas per Region no remote debugging
COMPETITORS?
COMPETITOR GOOGLE CLOUD FUNCTIONS JavaScript
COMPETITOR MICROSOFT AZURE FUNCTIONS JavaScript, C#, Python, PHP
ON PREMISE ?
COMPETITOR IBM BLUEMIX OPENWHISK Bluemix Cloud & OnPremise Open Source / Apache License v2.0 JavaScript (Node.js), Python and... Swi�! Docker Support Function-Chaining
IBM OPENWHISK LET'S GET STARTED $ git clone https://github.com/openwhisk/openwhisk.git $ cd openwhisk/tools/vagrant $ vagrant up
IBM OPENWHISK JAVASCRIPT EXAMPLE function main(params) { return {payload: 'Hello, ' + params.name}; } Create the action in OpenWhisk $ wsk action create hello hello.js Run the action $ wsk action invoke hello --blocking --result --param name Niko Result { "payload": "Hello, Niko" }
DRAWBACKS Overview: Documentation, Logging & Monitoring, Metrics ! (typical things for distributed environments) Cloud Provider Binding / Dependency: APIs, Portability, Costs, SLAs
CURIOUS ? WANT TO START? Give serverless.com a try! Manages all the Cloud-Resources and Deployment.
SERVERLESS.COM # Install serverless globally $ npm install serverless -g # Create an AWS Lamdba function in Node.js $ serverless create --template aws-nodejs # Deploy to live AWS account $ serverless deploy # Function deployed! $ http://api.amazon.com/users/update
SERVERLESS BUT POWERFUL No need to run/manage Application Servers Fast results, minimal effort, minimal TTM(!) Low costs, minimal financial risk Automatic Scalabiltiy and Availability "out-of-the-box"
THANK YOU ! ANY QUESTIONS ? Slides: http://bit.ly/serverless-slides Niko Köbler So�ware-Architect, Developer & Trainer niko@n-k.de www.n-k.de @dasniko | |
LINKS AWS Lambda: https://aws.amazon.com/lambda Amazon API Gateway: https://aws.amazon.com/api- gateway Google Cloud Functions: https://cloud.google.com/functions Microso� Azure Functions: https://azure.microso�.com/services/functions IBM OpenWhisk: https://developer.ibm.com/openwhisk IBM OpenWhisk SourceCode: https://github.com/openwhisk/openwhisk Serverless Framework: http://serverless.com
Recommend
More recommend