Slide 1

Slide 1 text

Life Without Server Yes we can!

Slide 2

Slide 2 text

Agenda ◉ Intro & background ◉ Serverless Paradigm (Background, State) ◉ Deep Dive on AWS Lambda ◉ Serverless Application Framework ◉ Demo, demo, demo :) ◉ Q&A

Slide 3

Slide 3 text

What I'll show you today...

Slide 4

Slide 4 text

It is the way in which you will work tomorrow…

Slide 5

Slide 5 text

TICKETS OPENED TO IT TEAMS infrastructure-dba-operations network-security-monitoring BEFORE DEPLOY A (Micro)Service TTM: over 2-3 months

Slide 6

Slide 6 text

Instant deployment Predictable performances Low latencies Fine Grain Services Decoupling “as usual” Continuous Development Deployment Monitoring

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

How we got to where we are

Slide 9

Slide 9 text

2017 A long time ago monolith micro-services functions Business Logic Shift containers virtualisation physical Cloud Evolution sysadmin dev-ops IT Culture months seconds Deploy Time days hours no-ops

Slide 10

Slide 10 text

Evolution CPU utilization in data centers (big public clouds) max min bare metal server virtualization containers serverless > 30% 5% 10-15% 20-25% The lower the utilization, the less value you’re getting for your money

Slide 11

Slide 11 text

Transactions Service Oriented Architecture Distributed Data / Services (ACID, 2PC, RPC) (past - then) exactly once delivery at least once delivery A long time ago 2017 Changes requires a massive shift in the way IT operates Message-Passing Shared-Nothing

Slide 12

Slide 12 text

Business Operations and Cloud Resources are deeply linked Monolith Micro-Services Functions Domain Driven Design Lean Agile Containers are the enablers for FaaS DevOps S.O.L.I.D.

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

doesn’t mean servers are no longer involved… It simply means that developers no longer have to think "that much" about them. “Why The Future Of Software And Apps Is Serverless”, Ken Fromm

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Jeff Conf - Milano 2017

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

“ Serverless computing is a major disruption from the mainstream, responding to requests for computation and processing data based on events and ensuring application code loads, executes, and runs with sufficient resources.

Slide 19

Slide 19 text

“ There’s a lot of similarity between a serverless approach and the philosophies of functional programming. Breaking down your application logic into small, discrete parts (or, pure functions) you can explicitly declare, test and control application logic in a demonstrable and repeatable way.

Slide 20

Slide 20 text

“ Moving away from servers and infrastructure concerns, as well as allowing the developer to primarily focus on code, is the ultimate goal behind serverless.

Slide 21

Slide 21 text

“ Serverless computing, generates cost efficiency by eliminating the need to scale up an entire application; instead, it distributes and scales only specific functions. The user pays only for the time function in serving the requests.

Slide 22

Slide 22 text

PaaS vs FaaS The big difference from PaaS and FaaS is the capacity of “scaling transparently”.

Slide 23

Slide 23 text

Specifications 1. It’s the next PaaS, where devs just write the business logic 2. Discrete services that react to events or requests 3. Scaled, fault tolerant and secure by provider 4. Significantly depend on third-party services 5. Cost-efficient: you will never pay for idle servers and you are charged by individual invocations

Slide 24

Slide 24 text

Pros No Provisioning & Zero Admin Full Managed Solid Security Model (by IAM) Simple Development & Deployment (a zip file) Reduced TTM & Developer Focused Pay Per Execution & Run when I need it Continuous Scaling & Fault Tolerance

Slide 25

Slide 25 text

Cons Less vendor control You can no longer store application & state data in local server memory There’s no dedicated hardware option with serverless Testing is more complicated We have some Lambda limits Vendor Lock-In

Slide 26

Slide 26 text

Complete serverless app’s requires a solid ecosystem of tools and services Serverless Cloud Platform

Slide 27

Slide 27 text

Building Blocks of AWS Serverless platform

Slide 28

Slide 28 text

Welcome to #servicefull AWS world where all is a service

Slide 29

Slide 29 text

Run Code, Not Server Welcome to FaaS

Slide 30

Slide 30 text

“ Lambda is to running code … … as S3 is to storing objects

Slide 31

Slide 31 text

Simple Storage Service ◉ Provide objects to S3 ◉ We don’t know how or where objects are stored ◉ S3 stores those objects transparently ◉ We don't have space or disks to manage ◉ We are charged only by amount stored

Slide 32

Slide 32 text

Lambda Computation Service ◉ Provide code to Lambda engine ◉ Lambda executes code on demand ◉ We don’t know how or where code are executed ◉ We don't have VM’s or containers to manage ◉ We are charged only by invocations / execution time

Slide 33

Slide 33 text

1 request 2 find 3 load 4 exec 5 response 0 deploy

Slide 34

Slide 34 text

distributed logic that react to changes in a distributed system Lambda is a reactive system

Slide 35

Slide 35 text

Event Driven model ◉ Code execution ○ Execution when triggered by an event ○ Fully automated (resources allocation) ◉ Require ○ An event source (where the event happens) ○ A function to execute (a zip package) ○ An event source mapping (metadata) ○ Right permissions (role & policies)

Slide 36

Slide 36 text

Event Sources ◉ What ? ○ Event sources sending events to lambda processing ○ Lambda then executes code by passing the event payload to the function handler ◉ Who ? ○ Api calls made by AWS SDK ○ Manual user invocation via the Web Console ○ HTTP requests through the Api Gateway ○ Scheduled (Cron/Jobs) ○ Events raised in AWS (S3, Kinesis, DynamoDb, etc..)

Slide 37

Slide 37 text

Event Sources List ◉ Supported AWS Event Sources ○ Amazon CloudWatch ○ Cognito ○ Api Gateway ○ Kinesis & DynamoDB ○ Simple Storage Service ○ Simple Notification Service ○ Simple Email Service ○ etc... ◉ Other AWS Services ○ Custom application ○ Services that publish event to above event sources

Slide 38

Slide 38 text

Lambda invocation ways ◉ Event (async) ○ Lambda function doesn’t send a response back to the event source. ○ Events are queued before being used to invoke the Lambda function (retry policies) ○ Used by S3, SNS ◉ Request-Response (sync) ○ Forces Lambda to execute the function synchronously and return the response to the caller. ○ Used by API Gateway, AWS Console, AWS SDK, etc.

Slide 39

Slide 39 text

Event models: Push vs Pull ◉ Push (non-stream based) ○ A service (like S3 o API Gateway) publishes an event to Lambda and directly invokes the function ○ Event source mapping reside in the service (S3) ◉ Pull (stream based) ○ Lambda runtime polls streaming event source (Kinesis or DynamoDB) and invokes the function when new data arrives. ○ Event source mapping reside in Lambda

Slide 40

Slide 40 text

EVENT SOURCES S3, SNS, API-G etc. ESM - PULL ESM - PUSH Async invoke Sync invoke Kinesis Streams and DynamoDB Streams Events are queued, support retries on errors and DLQ Event Source is responsible for retries

Slide 41

Slide 41 text

Event Source Mapping Sample

Slide 42

Slide 42 text

Amazon API Gateways Events (Push - ReqRes - Sync)

Slide 43

Slide 43 text

Amazon S3 Events (Push - Event - Async)

Slide 44

Slide 44 text

Amazon DynamoDB Events (Pull - Event - Async)

Slide 45

Slide 45 text

AWS Lambda Programming Model

Slide 46

Slide 46 text

Pillars 1. Function Handler 2. Context Object 3. Logging 4. Errors * all samples are for NodeJS runtime

Slide 47

Slide 47 text

Event: contains the input data (come from event source) Context: contains metadata about current execution Callback: returns errors or success message to the caller File JS: handler.js + Exports: hello = handler.hello

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

All logs are stored in Cloud Watch Lambda logs can be bound to an Elastic Search cluster

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

What about costs ?

Slide 53

Slide 53 text

$0.20 1 million requests ($0.0000002 per function invocation) 1 million requests per month are free

Slide 54

Slide 54 text

$0.00001667 for every GB-second Duration of execution (GB-s) rounded up to nearest 100ms First 400000 GB-s per month are free

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Make serverless apps, immediately

Slide 57

Slide 57 text

“ “Serverless model has the lowest TCO”

Slide 58

Slide 58 text

“ “Serverless model increases developer productivity and value”

Slide 59

Slide 59 text

“ “Serverless architectures are very large and complex, that are hard to maintains without help”

Slide 60

Slide 60 text

Key Features ● Application LifeCycle Management ● Manages Code & Infrastructure ● Scaffolding & Automation ● Multi-Runtimes (NodeJs, Java, Pyton, etc...) ● Permission Management (full IAM) ● Multi-Providers (less vendor lock-in) ● Local Development ● Extensibility in mind (plug-ins model) ● Open source ● Community Support ● and much more...

Slide 61

Slide 61 text

#Sign Up for Amazon Web Services https:/ /aws.amazon.com #Install AWS CLI https:/ /github.com/aws/aws-cli/releases Install serverless globally via npm npm install serverless -g Create an AWS Lambda project in Node.js serverless create --template aws-nodejs Install SLS framework

Slide 62

Slide 62 text

#serverless.yml service: intro provider: name: aws runtime: nodejs6.10 stage: dev region: eu-west-1 functions: hello: description: "Hello WebDev lambda!" handler: handler.hello Serveless YML “A Service is the Framework's unit of organization. You can think of it as a project file, though you can have multiple services for a single application. It's where you define your Functions, the Events that trigger them, and the Resources your Functions use”

Slide 63

Slide 63 text

Customize the handler #handler.js 'use strict'; module.exports.hello = (event, context, callback) => { callback(null, "Hello WebDev!"); };

Slide 64

Slide 64 text

Lambda Go live!

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

Live Coding A sample to see Serverless Framework in action ➔ step by step: ➔ create an Hello World API ➔ deploy the API to un AWS environment ➔ invoke the API endpoint to see it working ➔ add a function and new endpoint to the API ➔ deploy the updated API ➔ invoke the new endpoint

Slide 67

Slide 67 text

Demos An array of samples ➔ 01 - Intro ➔ 02 - events ➔ 03 - rest api recipes ➔ 04 - graphql api ➔ 05 - graphql api offline ➔ 06 - dynamodb stream ➔ 07 - step functions

Slide 68

Slide 68 text

Questions ? You can find us at ● [email protected] ● https://github.com/lucamilan Thanks!