Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

Post on 21-Jan-2018

204 views 2 download

Transcript of Rafal Gancarz - Serverless for the Enterprise - Codemotion Milan 2017

Serverless for the EnterpriseRafal Gancarz

CODEMOTION MILAN - SPECIAL EDITION 10 – 11 NOVEMBER 2017

@RafalGancarz

AIR ASIA HANDLES UP TO 40 MILLION REQUESTS PER DAY

@RafalGancarz

THOMSON REUTERS PROCESSES UP TO 10,000 EVENTS PER SECOND

(25 BILLION EVENTS PER MONTH)

@RafalGancarz

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

@RafalGancarz

Rafal GancarzIT Consultant @ Starbucks

@RafalGancarz

@RafalGancarz

WHAT IS SERVERLESS?

(CC) theaucitron

@RafalGancarz

Cloud-native

@RafalGancarz

Platform as a Service (PaaS)

@RafalGancarz

Event-driven

@RafalGancarz

Managed

@RafalGancarz

Serverless ≠ FaaS

Faas

Serverless

FaaS = Function as a Service

@RafalGancarz

WHY SERVERLESS?

(CC) snapp3r

@RafalGancarz

Availability

at $0

@RafalGancarz

Scalability

0 … 1000 …

@RafalGancarz

Economy

pay per use

@RafalGancarz

Time to market

months -> days

@RafalGancarz

Security

in depth

@RafalGancarz

Operability

from the start

@RafalGancarz

Culture

Agile/DevOps

(CC) Neil Tackaberry ENTERPRISE REQUIREMENTS

PERFORMANCE RESPONSIVENESS

SCALABILITY AVAILABILITY, ELASTICITY

SECURITY AUDITABILITY, COMPLIANCE

OPERABILITY OBSERVABILITY, SUPPORTABILITY

FLEXIBILITY EVOLVABILITY, MAINTAINABILITY

VIABILITY SUITABILITY, DELIVERABILITY, ECONOMICS

(CC) Ray Sadler

BUILDING BLOCKS

@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

@RafalGancarz

Execution modelevent + context

callback (err, data) (NodeJS)

return value (Java, Python, C#)

@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’));};

@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')

@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

@RafalGancarz

Image resizer

S3 object

S3 bucket Lambda function

upload

notification

put

@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>

@RafalGancarz

NPM Registry

API handler

API Gateway

publisherupload

NPM package tarball

@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

@RafalGancarz

CRUD API

API handler

API Gateway

DynamoDB table

record processor

DynamoDB table

trigge

r

@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

@RafalGancarz

Async tasks

API handler

API Gateway

DynamoDB table

SNS topic

task executor

@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

@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

@RafalGancarz

Persistent consumers

API handler

API Gateway

SNS topic

SQS queue

(CC) Tim Lumley

ECOSYSTEM

@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)

@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

@RafalGancarz

Serverless Ecosystem (Azure)

Cosmos DB

Machine Learning

Text Analytics API

Face API

Compute Vision API

Analytics Services

@RafalGancarz

single cloud vs multi-cloud

(CC) perceptions

ARCHITECTURE PATTERNS

@RafalGancarz

Serverless Monolith

@RafalGancarz

Serverless Microservices

A B C

D

@RafalGancarz

Sync integrationA B

HTTPS (IAM/?)

HTTPS (IAM)

@RafalGancarz

Async integrationA B

@RafalGancarz

Async notificationsA B

(CC) etherlore

CONTINUOUS DELIVERY

DEPLOYMENT

@RafalGancarz

Infrastructure provisioningA

AWS CloudFormation

(SAM)

Hashicorp Terraform

(S3 remote state)

@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

@RafalGancarz

Infrastructure provisioningCI/CD orchestrator

A

B

CDEVELOPMENT

A

B

CTESTING

A

B

CSTAGING

A

B

CPRODUCTION

@RafalGancarz

Code deployments

ES 2015

+rollupjs.org babeljs.io

apex.run

@RafalGancarz

Testing

Unit testing (local/CI)

Acceptance testing (test environment)

Smoke testing (post deployment)

testing pyramid

Component testing (dev environment)

@RafalGancarz

Testing

+ +

Unit testing (local + CI)

+

Acceptance/functional testing (AWS)

+

Smoke testing (AWS)

+

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

(CC) haru__q

SECURITY

@RafalGancarz

Security in depth

A B

team

CI/CD

IAM

IAM STS

IAM

IAM / API KEY / STS / CUSTOM

@RafalGancarz

AWS Parameter Store

scalable, managed, secured

configuration values and secrets

@RafalGancarz

Secret storage

API handler

API Gateway

secret

KMS

ciphertext

plaintext

key

generate key

(CC) Grégoire Lannoy

MONITORING

@RafalGancarz

AWS CloudWatch

scalable, managed

real-time monitoring

metrics, logs, alarms, events

Stackdriver n/a

(CC) Jérôme S

METRICS

@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

ALERTING(CC) Martin Abegglen

@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

@RafalGancarz

Serverless Alerting

function

CW alarm

SNS topic

email

SMS

channel

CW metric

condition

LOGGING

(CC) Mari Smith

@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

@RafalGancarz

Log Collection

CloudWatch log group

Lambda service

stdout

Lambda function

stderr

@RafalGancarz

Log Filtering

CloudWatch log group

CloudWatch metric

CloudWatch alarm

filter condition

@RafalGancarz

Log Browsing

log group Elastic Search

function

JSON

Kibana

Bunyan

EVENTS

(CC) JD Hancock

@RafalGancarz

CloudWatch Events

stores & streams application events

$1 per 1 million custom events

@RafalGancarz

Scheduled tasks

function

SDK

event

metrics

table

HEALTH CHECKS

(CC) Rosmarie Voegtli

@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

@RafalGancarz

Health Checks

health check

metric alarm

api function table

TRACING

(CC) Ozzy Delaney

@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

AUDITING

(CC) The Steve

@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

CHALLENGES(CC) mangpages

@RafalGancarz

Infancy

@RafalGancarz

Rapid Evolution

@RafalGancarz

Provider Lock-in

@RafalGancarz

Capacity management (Lambda, DynamoDB, Kinesis Streams)

@RafalGancarz

Frameworks

@RafalGancarz

Tooling

THE FUTURE

(CC) matt northam

@RafalGancarz

Maturity

@RafalGancarz

Services & Tools

@RafalGancarz

Patterns

@RafalGancarz

Business Agility

(CC) Alan Turkus

THANK YOU! QUESTIONS?

@RafalGancarz