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

Serverless Microservices

Niko Köbler
November 03, 2016

Serverless Microservices

Niko Köbler

November 03, 2016
Tweet

More Decks by Niko Köbler

Other Decks in Programming

Transcript

  1. HOW SMALL CAN YOU GO? MICROSERVICES SERVERLESS (WITH AWS )

    LAMBDA Niko Köbler So ware-Architect, Developer & Trainer | | [email protected] www.n-k.de @dasniko
  2. FUNCTIONS Running own code (function) in an external, sandboxed, stateless

    (and transient) compute container. No application server, no embedded server no Docker ;-)
  3. AWS LAMBDA Event Driven JVM-based languages (Java 8), JavaScript (Node.js),

    Python, (more to come) AWS Libraries are available at runtime Versions, Aliases via ARNs calculating time based costs, 100ms blocks (e.g. 100ms w/ 128MB memory = USD 0.000000208)
  4. AWS LAMBDA EXAMPLE NODE exports.handler = (event, context) => {

    console.log('Received event:', JSON.stringify(event)); }
  5. AWS LAMBDA EXAMPLE JAVA 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; } }
  6. AWS EVENTS LAMBDA S3 Cloud Watch Config DynamoDB Cloud Formation

    Kinesis Cognito SES Cron AWS IoT SNS API Gateway (no complete list)
  7. GATEWAY API "Reverse Proxy" hides possible multiple service calls (aka

    "service composition", ESB?) distributes requests to proper service instances "Mock" services
  8. GATEWAY API "Reverse Proxy" hides possible multiple service calls (aka

    "service composition", ESB?) distributes requests to proper service instances "Mock" services
  9. GATEWAY API AUTHENTICATION / AUTHORIZATION AWS Cognito / STS Custom

    Authorizer (Lambda Function, returning IAM policies)
  10. COMPETITOR IBM BLUEMIX OPENWHISK Bluemix Cloud & OnPremise Open Source

    / Apache License v2.0 JavaScript (Node.js), Java (?) Python and... Swi ! Docker Support Function-Chaining
  11. 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" }
  12. DRAWBACKS Overview: Documentation, Logging & Monitoring, Metrics ! (typical things

    for distributed environments) Cloud Provider Binding / Dependency: APIs, Portability, Costs, SLAs
  13. 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 "Powered by AWS Lambda"
  14. BUT POWERFUL SERVERLESS 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"
  15. LINKS AWS Lambda: Amazon API Gateway: Google Cloud Functions: Microso

    Azure Functions: IBM OpenWhisk: IBM OpenWhisk SourceCode: Serverless Framework: https://aws.amazon.com/lambda https://aws.amazon.com/api- gateway https://cloud.google.com/functions https://azure.microso .com/services/functions https://developer.ibm.com/openwhisk https://github.com/openwhisk/openwhisk http://serverless.com