69
Nome Speaker @twitter \ Si fa presto a dire Serverless Daniel Depaoli @dedaniel_xp Alessio Coser @AlessioCoser

Si fa presto a dire serverless

Embed Size (px)

Citation preview

Nome Speaker@twitter

\ Si fa presto a dire Serverless

Daniel Depaoli@dedaniel_xp

Alessio Coser@AlessioCoser

\ Si fa presto a dire Serverless

What we are going to talk about?

1. Introduction to Serverless2. Our Dev Experience3. Our Ops Experience

\ Si fa presto a dire Serverless

What is Serverless?

\ Si fa presto a dire Serverless

What is Serverless?

\ Si fa presto a dire Serverless

Function as a Service

\ Si fa presto a dire Serverless

What is a Function?

Custom code that’s run in an ephemeral context.

\ Si fa presto a dire Serverless

What is a Function?

Custom code that’s run in an ephemeral context.

● The code/application that we want to execute● The Service we provide to our users● Responds to events

\ Si fa presto a dire Serverless

What is a Function?

● Created only to run your code and then destroyed● Has no state or persistence● It’s still a server!

Custom code that’s run in an ephemeral context.

\ Si fa presto a dire Serverless

What is a Function?

\ Si fa presto a dire Serverless

Functions

Application

Runtime

Operating System

Virtualization

Hardware

IaaS

Customer Managed Unit of scale

Customer Managed

Abstract by vendor

\ Si fa presto a dire Serverless

Functions

Application

Runtime

Operating System

Virtualization

Hardware

Functions

Application

Runtime

Operating System

Virtualization

Hardware

IaaS PaaS

Customer Managed Unit of scale

Customer Managed

Abstract by vendor

\ Si fa presto a dire Serverless

Functions

Application

Runtime

Operating System

Virtualization

Hardware

Functions

Application

Runtime

Operating System

Virtualization

Hardware

Functions

Application

Runtime

Operating System

Virtualization

Hardware

IaaS PaaS FaaS

Customer Managed Unit of scale

Customer Managed

Abstract by vendor

\

● No infrastructure maintenance● Built-in automatic scaling● Only pay for the execution time● No persistence, no state● Limited execution time● Fully integrated with cloud provider’s services

Si fa presto a dire Serverless

Main features

\ Si fa presto a dire Serverless

Cloud-Computing Providers

● Amazon AWS Lambda● Google Cloud Functions● Azure Functions

\ Si fa presto a dire Serverless

Runtimes● NODE.JS● JAVA ● PYTHON● More

Nome Speaker@twitter

\ Our Dev experience

Si fa presto a dire Serverless\

\

\ Our Dev experiences

aws.amazon.com/solutions/case-studies/photovogue

\ Our Dev experiences PhotoVogue

\

An online photography platform

● Allows upcoming photographers to showcase their work.

● Each picture that’s submitted is carefully reviewed by Vogue Italia’s editorial staff.

Our Dev experiences PhotoVogue

\

● ~ 400,000 photos● ~ 130,000 photographers● ~ 3,000 uploaded images each day

An online photography platform

Our Dev experiences PhotoVogue

\ Our Dev experiences PhotoVogue

● Application that scales● No state or sessions● No long running scripts● Upload and resize of photos in parallel

How FaaS applies to the domain

\

Upload and resize feature

Our Dev experiences PhotoVogue

FaaS

EVENT

S3UPLOAD

RESIZED IMAGES

AWS

\

\ Benefits

Our Dev experiences PhotoVogue

\

Zero downtime deployment

Our Dev experiences PhotoVogue

\

> 1 deploy per day

Our Dev experiences PhotoVogue

\

Autoscaling

Our Dev experiences PhotoVogue

\

Average of~ 650 invocation/minute

Our Dev experiences PhotoVogue

\

Maximum peaks> 1500 invocation/minute

Our Dev experiences PhotoVogue

\

(as long as an entire AWS region does not crash)

[image]

Our Dev experiences PhotoVogue

No downtime

\

\ Challenges

Our Dev experiences PhotoVogue

\

Vendor lock-in

Our Dev experiences PhotoVogue

\

Decouple business logic from the cloud platform

Our Dev experiences PhotoVogue

\

Use a Framework like Serverless

Our Dev experiences PhotoVogue

\

Dependencies

Our Dev experiences PhotoVogue

\

Very common problem:You have two distinct functionalities, and

they share some of their code

Our Dev experiences PhotoVogue

\

1st solution:Create a single function which responds

to two different events

Our Dev experiences PhotoVogue

\

Easy to updateNo dependencies to manage

Big functionViolates Single Responsibility Principle

Our Dev experiences PhotoVogue

\

2nd solution:Create two different functions with the

same code

Our Dev experiences PhotoVogue

\

Common parts are easier to shareNo dependencies to manage

Deploy takes longerUnnecessary dependencies are also shared

Must deploy each function to update common code

Our Dev experiences PhotoVogue

\

3rd solution:Create two different functions with an

external shared dependency (es: git, npm)

Our Dev experiences PhotoVogue

\

No duplicated codeCan use different versions of dependency

Startup time increasesYou have to manage an external library

Our Dev experiences PhotoVogue

\

4th solution:Create two different functions that will

invoke a third one (containing the shared behaviour)

Our Dev experiences PhotoVogue

\

No duplicated codeCan use different versions of common function

Execution time increasesAdditional point of failure

Our Dev experiences PhotoVogue

\

There isn’t a perfect solution

Our Dev experiences PhotoVogue

Nome Speaker@twitter

\ Our Ops experiences

Si fa presto a dire Serverless\

\

\ Our Ops experiences

\ Disaster Recovery and Testing

\

A Disaster Recovery implementation

Our Ops experiences Disaster Recovery and Testing

\ Our Ops experiences Disaster Recovery and Testing

AWS does not provide a DR solution

\

1. Backupa. Every night create VMs snapshotb. Move snapshots to another AWS region

Our Ops experiences Disaster Recovery and Testing

Our implementation with FaaS

\

2. Recoverya. Activate the new environment in alternative region with

lastest snapshots

3. Testa. Check services and send notification

Our Ops experiences Disaster Recovery and Testing

Our implementation with FaaS

\ Our Ops experiences

\ Interaction with infrastructure

\

Sometimes we need to schedule a task

Our Ops experiences Interaction with infrastructure

\ Our Ops experiences Interaction with infrastructure

Load Balancer

Instance InstanceInstance task

Master

● Lambda direct SSH connection to instance● Triggering or doing particular tasks

\

● Check Backup S3● Dump DB● Clean EFS● Etc.

Our Ops experiences Interaction with infrastructure

Some example:

\ Our Ops experiences

\ Operations and monitoring

\

Simulating user browsing session

Our Ops experiences Monitoring

\ Our Ops experiences Monitoring

\

Integration with versioning system hosting service

Our Ops experiences CI/CD

\

\ Benefits

Our Ops experiences Monitoring

\

No third party tools

Our Ops experiences

\

No instances for just one task

Our Ops experiences

\ Our Ops experiences

Trigger one shot action

\

Fully integrated with other AWS services

Our Ops experiences

Conclusions

\

FaaS - when?Conclusions

● You need to simplify operational tasks● Your app needs to scale● Your domain logic is event based● You need to process a large quantity of

data

\

● You want some form of control over the infrastructure

● You have to maintain some state into the app● Your functions take a long time to run

FaaS - when not?Conclusions

Nome Speaker@twitter

\ Thanks!

PS: We are hiring -> www.xpeppers.com/carriere

Nome Speaker@twitter

\ Questions?

PS: We are hiring -> www.xpeppers.com/carriere

www.xpeppers.com

/xpepperssrl@xpeppers