ganz ohne server: betreiben hockskalierbarer aws-de-media.s3. breakfast... ganz ohne server:...

Download Ganz ohne Server: Betreiben hockskalierbarer aws-de-media.s3. Breakfast... Ganz ohne Server: Betreiben

Post on 11-Jul-2020




0 download

Embed Size (px)


  • Ganz ohne Server: Betreiben hockskalierbarer

    Microservices mit AWS Lambda

    Oliver Arafat, Enterprise Evangelist AWS


    Microservices Webday

  • Agenda

    • A simple problem, a complicated solution

    • What is AWS Lambda?

    • Pricing

    • Common Use-Cases

    • Demo

  • Simple Problem:

    Let’s make a microservice to thumbnail an image as soon as it’s uploaded

    into a repository.

  • • Provision a fleet of proxy machines to capture


    • For each upload, enqueue a job to process it.

    • Provision a second fleet of machines to read and

    process jobs.

    • Pick a deployment solution.

    • Plan capacity, accounting for fault tolerance, good

    long-term utilization, burst capability, etc.

    • Monitor 24x7x365 for capacity, health, security, etc.

    • Migrate to new instance types over time, keeping OS

    and language runtimes patched and up to date.

  • What if there was a better way?

    Please meet AWS Lambda.

  • What if every AWS service generated events…?








    … and you could respond to them easily?

  • Event-Driven Compute

    – Stateless, request-driven code called Lambda


    – Triggered by events in other services:

    • S3

    • DynamoDB Streams

    • Amazon Kinesis Streams

    • Amazon SNS

    • Amazon Cognito

    • CloudTrail Audit Logs

  • AWS Lambda: Hello World!

    // import any 3rd party library you want

    exports.handler = function(event, context) {

    context.succeed(‘Hello ’ + event.param); //'Something went wrong');


  • Push Event Model

    • Unordered model

    • 3 retries

  • Pull Event Model

    • Ordered model with multiple records per event

    • Unlimited retries (until data expires)

  • No Infrastructure to Manage

    Focus on business logic, not infrastructure.

    Just upload your code; AWS Lambda handles:




    Fault tolerance



    Web service front end

    Security patching

  • Automatic scaling

    • Each event becomes a Lambda request

    (hands free delivery) • For example, each object uploaded to Amazon S3

    is an event

    • Lambda scales to match the event rate

    • You can’t over or under provision

    • You pay only for what they use

  • Bring your own code (BYOC)

    • Create threads and processes

    • Run batch scripts or other executables

    • Read/write files in /tmp

    • Include any library with a Lambda

    function code, even native libraries

  • Intelligent Infrastructure

    • Turn storage services like Amazon S3 and

    Amazon Dynamo into dynamic, reactive services.

    • Attach code to a stream so that it can

    automatically aggregate or transform data

    flowing through.

    • Cost effectively add even small amounts of code,

    like audit checks, where you need them.

  • Amazon EC2/ECS

    • Hourly infrastructure rental

    • Flexible – choose your OS

    and instance type

    • DIY fault tolerance

    • Scale by provisioning

    more instances

    • Any code, any language

    Comparing AWS Compute Offerings

    AWS Lambda

    • Request-driven

    • Simple – shared OS,

    AWS-owned infrastructure

    • Built-in fault tolerance

    • Scale by sending more requests

    • Stateless Node.js and Java code

  • Pricing

  • Fine-grained pricing

    • Compute time is charged by 100ms, so even short jobs make sense

    • Low per request charge

    • No hourly, daily, or monthly minimums

    • Free tier

  • Pricing Example (1)

    Total Charges = Compute Charges + Request Charges

    Compute Charges:

    • First 1 million requests per month are free

    • $0.20 per 1 million requests thereafter ($0.0000002 per request)

    Request Charges:

    • $0.00001667 for every GB-second

  • Pricing Example (2)

    If you allocated 128MB of memory to your function,

    executed it 30 million times in one month, and it ran for 200ms each time,

    your charges would be calculated as follows:

    Total compute (seconds) = 30M * (0.2sec) = 6,000,000 seconds

    Total compute (GB-s) = 6,000,000 * 128MB/1024 = 750,000 GB-s

    Total Compute – Free tier compute = Monthly billable compute seconds

    750,000 GB-s – 400,000 free tier GB-s = 350,000 GB-s

    Monthly compute charges = 350,000 * $0.00001667 = $5.83

    30M requests – 1M free tier requests = 29M Monthly billable requests

    Monthly request charges = 29M * $0.2/M = $5.80

    Total charges = Compute charges + Request charges = $5.83 + $5.80 = $11.63 per month

  • Common Use Cases

  • Data Triggers: Amazon S3

    Amazon S3 Bucket Events AWS Lambda

    Original image Thumbnailed image




  • Data Triggers: DynamoDB

    AWS Lambda

     DynamoDB

    Table and Stream

    Send Amazon SNS


    Update another table

  • Audit and Notify

    AWS API calls

    AWS CloudTrail Logs

    AWS Lambda

    Bucket events Amazon SNS notifications

  • Custom Events

    AWS Lambda

  • Serverless Microservices

    AWS Lambda

     API Gateway

  • Demo

  • Migrating a NODE.JS Service to AWS Lambda

  • Migrating a NODE.JS Service to AWS Lambda

  • Migrating a NODE.JS Service to AWS Lambda

  • AWS Free Tier

  • Thank you!


    Oliver Arafat, Enterprise Evangelist AWS


    Microservices Webday


View more >