101
Serverless for the Enterprise Rafal Gancarz CODEMOTION MILAN - SPECIAL EDITION 10 – 11 NOVEMBER 2017

Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

Embed Size (px)

Citation preview

Page 1: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

Serverless for the EnterpriseRafal Gancarz

CODEMOTION MILAN - SPECIAL EDITION 10 – 11 NOVEMBER 2017

Page 2: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AIR ASIA HANDLES UP TO 40 MILLION REQUESTS PER DAY

Page 3: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

THOMSON REUTERS PROCESSES UP TO 10,000 EVENTS PER SECOND

(25 BILLION EVENTS PER MONTH)

Page 4: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

FINRA EXECUTES 500 BILLION DATA VALIDATIONS ON 37 BILLION MARKET EVENTS EVERY DAY

Page 5: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Rafal GancarzIT Consultant @ Starbucks

@RafalGancarz

Page 6: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

WHAT IS SERVERLESS?

Page 7: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) theaucitron

Page 8: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Cloud-native

Page 9: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Platform as a Service (PaaS)

Page 10: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Event-driven

Page 11: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Managed

Page 12: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless ≠ FaaS

Faas

Serverless

FaaS = Function as a Service

Page 13: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

WHY SERVERLESS?

Page 14: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) snapp3r

Page 15: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Availability

at $0

Page 16: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Scalability

0 … 1000 …

Page 17: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Economy

pay per use

Page 18: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Time to market

months -> days

Page 19: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Security

in depth

Page 20: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Operability

from the start

Page 21: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Culture

Agile/DevOps

Page 22: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) Neil Tackaberry ENTERPRISE REQUIREMENTS

Page 23: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

PERFORMANCE RESPONSIVENESS

Page 24: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

SCALABILITY AVAILABILITY, ELASTICITY

Page 25: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

SECURITY AUDITABILITY, COMPLIANCE

Page 26: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

OPERABILITY OBSERVABILITY, SUPPORTABILITY

Page 27: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

FLEXIBILITY EVOLVABILITY, MAINTAINABILITY

Page 28: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

VIABILITY SUITABILITY, DELIVERABILITY, ECONOMICS

Page 29: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) Ray Sadler

BUILDING BLOCKS

Page 30: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS LambdaJava, C#, NodeJS, Python

sync & async invocation

max 5 minutes execution time

1 million invocations and 400k GB-s free per month

$0.20 per 1 million requests and ~$6.65 for 400k GB-s thereafter

Cloud Functions Functions

Page 31: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Execution modelevent + context

callback (err, data) (NodeJS)

return value (Java, Python, C#)

Page 32: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Hello World (NodeJS)console.log(‘Loading function’)

exports.handler = (event, context, callback) => { // console.log(JSON.stringify(event)); // your logic goes here callback(null, 'Hello from Lambda’); // callback(new Error(‘something went wrong’));};

Page 33: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Hello World (Python)from __future__ import print_function

import json

print('Loading function')

def lambda_handler(event, context): print("Received event: " + json.dumps(event, indent=2))

// your logic goes here

return “Hello from Lambda” #raise Exception('Something went wrong')

Page 34: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS S3durable, available and scalable

functions as content processors

5 GB of storage and 15 GB of data transfer out to Internet each month for free

$0.03 per TB/month and $0.09 per GB data transfer out to Internet

Cloud Storage Blob Storage

Page 35: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Image resizer

S3 object

S3 bucket Lambda function

upload

notification

put

Page 36: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS API Gateway

security, caching, throttling

functions as API implementations

1 million requests free per month

$3.50 per 1 million requests and $0.09/GB (for the first 10 TB, then cheaper)

Cloud Endpoints <integrated>

Page 37: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

NPM Registry

API handler

API Gateway

publisherupload

NPM package tarball

Page 38: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS DynamoDBdocument and key-value

function as triggered procedures

25 GB of storage and 25 units of read capacity each month for free (~200k requests per month)

$0.25 per GB/month and $0.0065 per hour for 10 units of write capacity (36k writes/hour) or 50 units of read capacity (180k reads/hour)

Firebase, Bigtable DataStore Table Storage

Page 39: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

CRUD API

API handler

API Gateway

DynamoDB table

record processor

DynamoDB table

trigge

r

Page 40: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS SNSpub-sub, push notifications

functions as destinations

1m publishes, 1m mobile push notifications, 1k emails, 100k HTTP notifications and 1 GB of data transfer out each month for free

$0.50 per 1m publishes, $0.60 per 1m HTTP notifications and $0.09 per GB data transfer out to the Internet

Cloud Pub/Sub Queue Storage, Event Grid

Page 41: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Async tasks

API handler

API Gateway

DynamoDB table

SNS topic

task executor

Page 42: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS Kinesis Streams

pub-sub, persistent

functions as consumers

no free tier

$0.015 per shard/hour, $0.014 per 1m PUT payload units (25KB) + extended retention charges

data transfer is free

Cloud Pub/Sub Queue Storage

Page 43: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS SQSpoint to point messaging, persistent

poll based API, functions need to consume messages explicitly

1m requests (API actions or messages) each month for free

$0.40 per 1m requests (standard) or $0.50 per 1m requests (FIFO)

Cloud Pub/Sub Queue Storage

Page 44: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Persistent consumers

API handler

API Gateway

SNS topic

SQS queue

Page 45: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) Tim Lumley

ECOSYSTEM

Page 46: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless Ecosystem (AWS)

SES

LEX

Cloud Front

Route53

KMS

Cognito

Step Functions

SecurityDelivery

Mes

sagi

ng

Glacier

RDS

RedshiftElasti Cache

Athena

EMRESStorage & Analytics

Artificial Intelligence

PollyRekognition

Operations

IoTAlexa Skills

Internet of Things

Com

pute

Cloud Trail

Batch

ECS

EC2

Legend: no servers in sight servers visible servers visible (VPC)

Page 47: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless Ecosystem (GCP)Machine Learning

Cloud Natural Language API

Cloud Speech API

Cloud Translation API

Cloud Vision API

Cloud Video Intelligence API

Cloud Pub/Sub

Cloud Spanner

Page 48: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless Ecosystem (Azure)

Cosmos DB

Machine Learning

Text Analytics API

Face API

Compute Vision API

Analytics Services

Page 49: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

single cloud vs multi-cloud

Page 50: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) perceptions

ARCHITECTURE PATTERNS

Page 51: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless Monolith

Page 52: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless Microservices

A B C

D

Page 53: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Sync integrationA B

HTTPS (IAM/?)

HTTPS (IAM)

Page 54: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Async integrationA B

Page 55: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Async notificationsA B

Page 56: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) etherlore

CONTINUOUS DELIVERY

DEPLOYMENT

Page 57: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Infrastructure provisioningA

AWS CloudFormation

(SAM)

Hashicorp Terraform

(S3 remote state)

Page 58: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Build/deployment pipeline

1 checkout

build (compile/transpile + execute unit tests)

deploy to DEVELOPMENT environment + execute component/API tests

deploy to TESTING environment + execute end to end tests

deploy to STAGING environment + execute smoke tests

deploy to PRODUCTION environment + execute smoke tests

2

3

4

5

6

Page 59: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Infrastructure provisioningCI/CD orchestrator

A

B

CDEVELOPMENT

A

B

CTESTING

A

B

CSTAGING

A

B

CPRODUCTION

Page 60: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Code deployments

ES 2015

+rollupjs.org babeljs.io

apex.run

Page 61: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Testing

Unit testing (local/CI)

Acceptance testing (test environment)

Smoke testing (post deployment)

testing pyramid

Component testing (dev environment)

Page 62: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Testing

+ +

Unit testing (local + CI)

+

Acceptance/functional testing (AWS)

+

Smoke testing (AWS)

+

(mochajs.org) (chaijs.com) (sinonjs.org) (proxyquire)

Page 63: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) haru__q

SECURITY

Page 64: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Security in depth

A B

team

CI/CD

IAM

IAM STS

IAM

IAM / API KEY / STS / CUSTOM

Page 65: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS Parameter Store

scalable, managed, secured

configuration values and secrets

Page 66: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Secret storage

API handler

API Gateway

secret

KMS

ciphertext

plaintext

key

generate key

Page 67: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) Grégoire Lannoy

MONITORING

Page 68: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS CloudWatch

scalable, managed

real-time monitoring

metrics, logs, alarms, events

Stackdriver n/a

Page 69: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) Jérôme S

METRICS

Page 70: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

CloudWatch Metricsretention: 1m (15 days), 5m (63 days), 1h (15 months)

basic monitoring (1m/5m) is free

10 metrics and 1 million API requests for free each month

$0.30 per metric/month for the first 10k metrics ($0.02 for metrics over 1M)

$0.01 for 1000 API requests

Stackdriver Monitoring n/a

Page 71: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

ALERTING(CC) Martin Abegglen

Page 72: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

CloudWatch Alarms

watches metrics over time

can trigger a function via SNS

10 alarms per month for free

$0.10 per alarm per month

Stackdriver Monitoring n/a

Page 73: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Serverless Alerting

function

CW alarm

SNS topic

email

SMS

channel

CW metric

condition

Page 74: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

LOGGING

(CC) Mari Smith

Page 75: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

CloudWatch Logsingests and stores application logs

configurable retention period

5 GB data ingestion and 5 GB archived storage per month for free

$0.5985 per GB ingested per month

$0.0315 per GB archived per month

Stackdriver Logging n/a

Page 76: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Log Collection

CloudWatch log group

Lambda service

stdout

Lambda function

stderr

Page 77: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Log Filtering

CloudWatch log group

CloudWatch metric

CloudWatch alarm

filter condition

Page 78: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Log Browsing

log group Elastic Search

function

JSON

Kibana

Bunyan

Page 79: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

EVENTS

(CC) JD Hancock

Page 80: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

CloudWatch Events

stores & streams application events

$1 per 1 million custom events

Page 81: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Scheduled tasks

function

SDK

event

metrics

table

Page 82: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

HEALTH CHECKS

(CC) Rosmarie Voegtli

Page 83: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Route53 Health Checks

monitors HTTP(S) endpoints

50 AWS endpoint checks per month for free

$0.50 per health check per month

$1 per feature (HTTPS, string matching, fast interval, latency) per month

Page 84: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Health Checks

health check

metric alarm

api function table

Page 85: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

TRACING

(CC) Ozzy Delaney

Page 86: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS X-Ray

collects transaction traces

100k traces recorded and 1 million traces retrieved/scanned free per month

$5 per 1 million traces recorded and $0.50 per 1 million traces retrieved/scanned per month

Stackdriver Trace n/a

Page 87: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

AUDITING

(CC) The Steve

Page 88: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

AWS CloudTrail

audits all console, API, SDK activity

first copy of management event free

additional copies $2 per 100k events

$0.10 per 100k data events

Page 89: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

CHALLENGES(CC) mangpages

Page 90: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Infancy

Page 91: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Rapid Evolution

Page 92: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Provider Lock-in

Page 93: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Capacity management (Lambda, DynamoDB, Kinesis Streams)

Page 94: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Frameworks

Page 95: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Tooling

Page 96: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

THE FUTURE

(CC) matt northam

Page 97: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Maturity

Page 98: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Services & Tools

Page 99: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Patterns

Page 100: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

@RafalGancarz

Business Agility

Page 101: Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

(CC) Alan Turkus

THANK YOU! QUESTIONS?

@RafalGancarz