Slide 1

Slide 1 text

Michael Wittig | tecRacer The Life of a Serverless Microservice on AWS

Slide 2

Slide 2 text

Michael Wittig • Author of Amazon Web Services in Action (Manning) • AWS Consultant • tecRacer [email protected] @hellomichibye

Slide 3

Slide 3 text

Life • develop • test • deploy • operate

Slide 4

Slide 4 text

Serverless Dev Function Event

Slide 5

Slide 5 text

Serverless • only pay when function is executed – $0,0000002 + $0,000000208 / 100 ms – $1 := 2,5 mio invocations • 100% managed – no under/over provisioning – no boot time, no patching, no SSH – no load balancing

Slide 6

Slide 6 text

Serverless Events • File uploaded • E-Mail received • Database changed • Manual invoked • HTTP API called • Cron

Slide 7

Slide 7 text

Microservice Profile Auth Location User GET /profile/michael PUT /loc/michael

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Code CI & CD Service User Dev Logs Metrics Alerting

Slide 10

Slide 10 text

Code • AWS CodeCommit – hosted Git Repository – uses IAM for access control

Slide 11

Slide 11 text

Create Repository

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

CI & CD Service User Dev Logs Metrics Alerting

Slide 14

Slide 14 text

CI & CD • AWS CodePipeline – build, test, and deploy your code – product integrations • Solano Labs – CI as a Service

Slide 15

Slide 15 text

CI & CD • download sources • install dependencies: npm install • run tests: make test • bundle artifact: zip • deploy using CloudFormation – create / update stack

Slide 16

Slide 16 text

CI & CD • AWS CloudFormation – Infrastructure as Code – Pipeline as Code

Slide 17

Slide 17 text

Create Pipeline

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Service User Dev Logs Metrics Alerting

Slide 23

Slide 23 text

Service • Amazon API Gateway – REST API as a Service • AWS Lambda – code execution – event triggered • Amazon DynamoDB – Key-Value- / Document-Store

Slide 24

Slide 24 text

Service User

Slide 25

Slide 25 text

Service 1. check input 2. map input to JSON 3. call Lambda function 4. map output 5. check output • 100% managed

Slide 26

Slide 26 text

Service • implement interface • success / failure • limited memory • limited execution time • 100% managed

Slide 27

Slide 27 text

Service • read / write by key • replicated • eventual consistent • 99% managed – except scaling

Slide 28

Slide 28 text

Deploy Service

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

User Dev Logs Metrics Alerting

Slide 34

Slide 34 text

Logs, Metrics & Alerting • AWS CloudWatch – Metrics – Alarms – Logs

Slide 35

Slide 35 text

Logs, Metrics & Alerting Metric Alarm Filter Dev Source Log Group / Stream Source

Slide 36

Slide 36 text

Setup Monitoring & Alerting

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

User Dev

Slide 40

Slide 40 text

Summary

Slide 41

Slide 41 text

Logs & Monitoring CI & CD Test Git Deploy Profile Auth Locatio n Bundle JSON JS git push GET /profile/michael HTTP/1.1 PUT /loc/michael HTTP/1.1 Services Log s Metr ics Alertin g Alertin g Dev User Code • Service dependencies • Authentitcation

Slide 42

Slide 42 text

Code • https://github. com/michaelwittig/devopscon16-auth- service • https://github. com/michaelwittig/devopscon16-profile- service • https://github. com/michaelwittig/devopscon16- location-service • https://github.

Slide 43

Slide 43 text

Pittfals • CodePipeline / CodeCommit only available in us-east-1 at the moment • Soft limits – Concurrent Lambda invocations (100) – API Gateway RPS (1000) • CloudFormation, CodePipeline and Solano Labs has limitations

Slide 44

Slide 44 text

Use code ctwdevopstw at https://manning.com/wittig Michael Wittig [email protected] @hellomichibye github.com/michaelwittig Save 39%