SERVERLESS + CONTAINERS = MODERN CLOUD APPLICATIONS Donna Malayeri - - PowerPoint PPT Presentation

serverless containers modern cloud applications
SMART_READER_LITE
LIVE PREVIEW

SERVERLESS + CONTAINERS = MODERN CLOUD APPLICATIONS Donna Malayeri - - PowerPoint PPT Presentation

SERVERLESS + CONTAINERS = MODERN CLOUD APPLICATIONS Donna Malayeri Product Manager, Pulumi @PulumiCorp @lindydonna SERVERLESS AND CONTAINERS Tradeoff between control and productivity Containers give you full control over your compute


slide-1
SLIDE 1

SERVERLESS + CONTAINERS = MODERN CLOUD APPLICATIONS

Donna Malayeri Product Manager, Pulumi @PulumiCorp @lindydonna

slide-2
SLIDE 2
slide-3
SLIDE 3

@lindydonna

SERVERLESS AND CONTAINERS

  • Tradeoff between control and productivity
  • Containers give you full control over your compute workloads
  • Serverless scales instantly and is cheaper to own and operate
  • Modern applications need both compute models
slide-4
SLIDE 4

@lindydonna

PROGRAMMING IS ABOUT ABSTRACTION

  • JavaScript
  • Go
  • Python
  • Ruby
  • C#
  • Java
  • C/C++
  • Assembly

If I have seen further it is only by standing on the shoulders of giants.

  • - Isaac Newton
slide-5
SLIDE 5

Control Abstraction Virtual Machines Containers Serverless Containers Platform as a Service Serverless

The cloud landscape

slide-6
SLIDE 6

@lindydonna

  • How often should I patch my server?
  • How do I patch?
  • How do I deploy code?
  • How many servers do I need?
  • How can I scale my app?

IN THE EARLY DAYS OF CLOUD, THERE WERE ONLY VIRTUAL MACHINES

slide-7
SLIDE 7

@lindydonna

CONTAINERS REDUCE COMPLEXITY

Dockerfile Docker image Container orchestrator

slide-8
SLIDE 8

CONTAINERS

Dockerfile Docker image Container registry docker build AWS Elastic Container Service Task definition Service description

slide-9
SLIDE 9

@lindydonna

CONTAINER BENEFITS

  • Abstraction for compute: containers instead of VMs
  • Useful package format
  • Full control over application environment
  • Full control over task placement
  • Control over compute resources
slide-10
SLIDE 10

CONTAINERS AT RUNTIME

ECS Service Description Task definition Service description Graphic: https://medium.freecodecamp.org/amazon-ecs-terms-and-architecture-807d8c4960fd

slide-11
SLIDE 11

@lindydonna

CONTAINERS: THINGS TO MANAGE

  • How often should I update my Dockerfile dependencies?
  • How do I build my container images?
  • How do I get my containers in production?
  • How many servers do I need?
  • How can I scale my app?
slide-12
SLIDE 12

SERVERLESS: JUST PROVIDE YOUR CODE

Code zipfile

Cloud icons: https://www.flaticon.com/authors/payungkead

Cloud platform Trigger definition

slide-13
SLIDE 13

SERVERLESS

  • Event-driven compute with near-instant scale
  • Managed, ephemeral compute
  • Never pay for idle

(Btw, there are actually servers)

AWS Lambda Google Cloud Functions Azure Functions

slide-14
SLIDE 14

@lindydonna

WHY SERVERLESS?

  • Reduce operational overhead
  • Faster time to market
  • Focus on business value

The Serverless Spectrum https://read.acloud.guru/the-serverless-spectrum-147b02cb2292

slide-15
SLIDE 15

SCHEDULED TASKS

https://functions.azure.com

slide-16
SLIDE 16

CREATE IMAGE THUMBNAIL

https://aws.amazon.com/lambda/

slide-17
SLIDE 17

ANALYZE SOCIAL MEDIA STREAM

https://aws.amazon.com/lambda/

slide-18
SLIDE 18

@lindydonna

SERVERLESS CAVEATS

  • Works best for event-based workloads
  • Cloud vendor supports specific languages and runtimes
  • Can’t customize execution environment
  • Not well-suited for long-running tasks
slide-19
SLIDE 19

ANALOGY: RENTING VS OWNING A BIKE

slide-20
SLIDE 20

@lindydonna

NEW CONTAINER EXECUTION MODELS

  • Azure Container Instances
  • AWS Fargate
  • On-demand containers
  • Don’t have to manage underlying cluster
slide-21
SLIDE 21

@lindydonna

CONTAINERS AND SERVERLESS

  • Use containers for control over the execution environment
  • Customize software and physical servers
  • Great for long-running compute
  • Use serverless for event-based compute that scales on demand
  • Less to manage
  • Less to configure
slide-22
SLIDE 22

Control Abstraction Virtual Machines Containers Serverless Containers Platform as a Service Serverless

The cloud landscape

slide-23
SLIDE 23

COMBINING THE TWO

slide-24
SLIDE 24

EXAMPLE: VIDEO THUMBNAILER

Bucket

  • nNewVideo

Lambda New .mp4 file Launch task Write .jpg Bucket ECS Fargate Task ffmpegTask New .jpg file

  • nNewThumbnail

Lambda

slide-25
SLIDE 25

EXAMPLE: RAY TRACING scene.zip

ECS Cluster

slide-26
SLIDE 26

EXAMPLE: CONTENT MODERATION

Image

slide-27
SLIDE 27

EXAMPLE: FUNCTION CHAINING

const df = require("durable-functions"); module.exports = df(function*(ctx) { const x = yield ctx.df.callActivityAsync("F1"); const y = yield ctx.df.callActivityAsync("F2", x); const z = yield ctx.df.callActivityAsync("F3", y); return yield ctx.df.callActivityAsync("F4", z); });

slide-28
SLIDE 28

EXAMPLE: DURABLE FUNCTIONS

slide-29
SLIDE 29

TOOLS

slide-30
SLIDE 30

VENDOR DEPLOYMENT TOOLS AWS CLOUDFORMATION AZURE RESOURCE MANAGER GOOGLE CLOUD DEPLOYMENT MANAGER

slide-31
SLIDE 31

@lindydonna

TOOLS ALSO PROVIDE ABSTRACTION

  • Use Terraform modules
  • Use Serverless Framework plugins or components
  • Use Pulumi components
  • Examples: github.com/lindydonna/velocity-examples
slide-32
SLIDE 32

Control Abstraction Virtual Machines Containers Serverless Containers Platform as a Service Serverless

The cloud landscape

slide-33
SLIDE 33

CONTAINERS

Dockerfile Docker image Container registry docker build AWS Elastic Container Service Task definition Service description

slide-34
SLIDE 34

EXAMPLE: VIDEO THUMBNAILER

Bucket

  • nNewVideo

Lambda New .mp4 file Launch task Write .jpg Bucket ECS Fargate Task ffmpegTask New .jpg file

  • nNewThumbnail

Lambda

slide-35
SLIDE 35

DEFINING THE APP IN PULUMI

Dockerfile

  • nNewVideo
  • nNewThumbnail

ffmpegTask

FROM jrottenberg/ffmpeg RUN apt-get update && \ apt-get install python-dev python-pip -y && \ apt-get clean RUN pip install awscli WORKDIR /tmp/workdir ENTRYPOINT \ aws s3 cp s3://${S3_BUCKET}/${INPUT_VIDEO} ./${INPUT_VIDEO} && \ ffmpeg -i ./${INPUT_VIDEO} -ss ${TIME_OFFSET} -vframes 1 -f image2 -an -y ${OUTPUT_FILE} && \ aws s3 cp ./${OUTPUT_FILE} s3://${S3_BUCKET}/${OUTPUT_FILE}

slide-36
SLIDE 36

let bucket = new cloud.Bucket("bucket"); bucket.onPut("onNewThumbnail", async (bucketArgs) => { console.log(`*** New thumbnail: file ${bucketArgs.key}.`); }, { keySuffix: ".jpg" }); let ffmpegTask = new cloud.Task("ffmpegTask", { build: "./docker-folder", memoryReservation: 512, }); bucket.onPut("onNewVideo", async (bucketArgs) => { const file = bucketArgs.key; const framePos = ... // extract timestamp from filename await ffmpegTask.run({ environment: { "S3_BUCKET": bucket.id.get(), "INPUT_VIDEO": file, "TIME_OFFSET": framePos, "OUTPUT_FILE": file + '.jpg', }, }); }, { keySuffix: ".mp4" }); ECS task ECR repository ECS cluster Container image IAM roles

slide-37
SLIDE 37

EXAMPLE: PROVISION QUEUES

function createQueue(name, deadLetter) { return new aws.sqs.Queue(`${common.prefix}-${name}`, { ... }); } exports.certIssuer = { request: createQueue("c-i-req”, true), response: createQueue("c-i-res", true), prepare: createQueue("c-i-prep", true), initOrg: createQueue("c-i-init-org", true), initOrgRes: createQueue("c-i-init-org-res", true), confirmTxs: createQueue("confirm-tx"), };

slide-38
SLIDE 38

Control Abstraction Virtual Machines Containers Serverless Containers Platform as a Service Serverless

The cloud landscape

slide-39
SLIDE 39

@lindydonna

CONTAINERS WITH PULUMI

  • How often should I update my Dockerfile dependencies?
  • How do I build my container images?
  • How do I get my containers in production?
  • How many servers do I need?
  • How can I scale my app?
slide-40
SLIDE 40

@lindydonna

SUMMARY

  • Serverless and containers each have their place
  • Use serverless for event-based code that needs to scale on demand
  • Use containers for durable workloads, or to customize environment
  • Define abstractions using infrastructure-as-code tooling

Learn more at pulumi.io github.com/pulumi @PulumiCorp