Slide 1

Slide 1 text

Manage microservices like a Chef

Slide 2

Slide 2 text

Mathieu Acthernoene @zoontek

Slide 3

Slide 3 text

Microservices are awesome ✨

Slide 4

Slide 4 text

Microservices are awesome ✨ Each service is an app implementing its own business logic service database SaaS 1 SaaS 2

Slide 5

Slide 5 text

Microservices are awesome ✨ Separated by concern, easier to understand what's going on auth email sms …

Slide 6

Slide 6 text

Microservices are awesome ✨ They can evolve apart, deploy at different frequencies service 1 service 2 service 3 service 4 service 1 service 4 service 4

Slide 7

Slide 7 text

Microservices are awesome ✨ If one breaks, you don't have to reboot everything service 1 service 3 service 4

Slide 8

Slide 8 text

Microservices are awesome ✨ Scales according to the service needs, not globally CPU intensive service RAM intensive service GPU intensive service

Slide 9

Slide 9 text

Microservices are awesome ✨ Each service team is free to use the right tools service using couchDB service using JavaScript service using Golang

Slide 10

Slide 10 text

But

Slide 11

Slide 11 text

But

Slide 12

Slide 12 text

Just as you think you're making microservices

Slide 13

Slide 13 text

You might just not

Slide 14

Slide 14 text

You are not building microservices when… #

Slide 15

Slide 15 text

You are not building microservices when… # Changes needs to be synced service 1 service 1 change service 2

Slide 16

Slide 16 text

Deploys needs to be synced You are not building microservices when… # service 1 service 1 deploy service 2

Slide 17

Slide 17 text

The same developers work across a large number of them service 1 Kévin Sylvie Amine You are not building microservices when… # service 2 Kévin Luc Clarisse service 3 Kévin Zhang Nicolas

Slide 18

Slide 18 text

They share a datastore You are not building microservices when… # service 1 database service 2

Slide 19

Slide 19 text

They share a lot of the same code / models You are not building microservices when… # service 1 type User {} service 2 type User {} service 3 type User {}

Slide 20

Slide 20 text

You just created a distributed monolith crypto REST logging REST email REST sms REST storage REST billing REST

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Managing microservices is like managing a restaurant

Slide 23

Slide 23 text

waiter REST sous-chef REST pastry chef REST wine waiter REST washer REST chef REST

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

How does a restaurant manage services?

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

The “simple” gateway solution crypto REST logging REST email REST sms REST storage REST billing REST gateway REST

Slide 28

Slide 28 text

One interlocutor passing messages to the right services

Slide 29

Slide 29 text

The REST / JSON gateway issues ⚠ If a first API is RESTful, the twelfth iteration is RESTish service API v1 ✨ service API v3 … service API v9 …

Slide 30

Slide 30 text

Latency caused by serialization / deserialization service 1 service 2 API gateway decode JSON understand message create message encode JSON The REST / JSON gateway issues ⚠

Slide 31

Slide 31 text

You embed your model schemas in every messages { "login": "octocat", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", … The REST / JSON gateway issues ⚠

Slide 32

Slide 32 text

As a service owner, you have to wait for a complete implementation of another one to start using it service 1 is finished & deployed the API gateway implements service 1 service 2 starts implementing its usage of service 1 The REST / JSON gateway issues ⚠

Slide 33

Slide 33 text

As JSON types are basic (JavaScript interop…), a documentation is mandatory The REST / JSON gateway issues ⚠

Slide 34

Slide 34 text

How does a restaurant manage communication?

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

People working in the kitchen don't necessarily have the same mother tongue

Slide 37

Slide 37 text

They don't force their coworkers to use their language

Slide 38

Slide 38 text

Protobuf ↔

Slide 39

Slide 39 text

Protobuf ↔ Created by, and for Google in 2001

Slide 40

Slide 40 text

A binary format for typed exchanges Protobuf ↔

Slide 41

Slide 41 text

Protobuf ↔ Generate clients for C++, Java, Python, Go, Ruby, C#, JS, ObjC, PHP, Dart…

Slide 42

Slide 42 text

Offers backward compatibility for free Protobuf ↔

Slide 43

Slide 43 text

Offers a JSON mapping Protobuf ↔

Slide 44

Slide 44 text

Tooling and linters are available Protobuf ↔

Slide 45

Slide 45 text

Allows RPC methods definition Protobuf ↔

Slide 46

Slide 46 text

How to write a .proto file

Slide 47

Slide 47 text

syntax = "proto3";

Slide 48

Slide 48 text

package storage;

Slide 49

Slide 49 text

import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto";

Slide 50

Slide 50 text

option java_package = "com.scaleway.storage";

Slide 51

Slide 51 text

message Bucket { enum Attributes { LAZY = 0; DELUXE = 1; } string id = 1; google.protobuf.Timestamp created_at = 2; repeated Attributes attributes = 3; int32 old_field = 4 [deprecated=true]; }

Slide 52

Slide 52 text

service Storage { rpc ListBuckets(ListBucketsRequest) returns (stream Bucket) { option (google.api.http) = { get: "/buckets" }; } rpc GetBucket(GetBucketRequest) returns (Bucket) { option (google.api.http) = { get: "/buckets/{id}" }; } } message ListBucketsRequest { string user_id = 1; } message GetBucketRequest { string id = 1; }

Slide 53

Slide 53 text

syntax = "proto3"; package storage; option java_package = "com.scaleway.storage"; service Storage { rpc ListBuckets(ListBucketsRequest) returns (stream Bucket) { option (google.api.http) = { get: "/buckets" }; } rpc GetBucket(GetBucketRequest) returns (Bucket) { option (google.api.http) = { get: "/buckets/{id}" }; } } message Bucket { enum Attributes { LAZY = 0; DELUXE = 1; } string id = 1; google.protobuf.Timestamp created_at = 2; repeated Attributes attributes = 3; int32 old_field = 4 [deprecated=true]; } message ListBucketsRequest { string user_id = 1; } message GetBucketRequest { string id = 1; }

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

I get Protobuf, but what is gRPC ? HTTP/2 clients for Protobuf messages transport

Slide 56

Slide 56 text

Unaries, uni- and bi-directional streams I get Protobuf, but what is gRPC ?

Slide 57

Slide 57 text

Blocking & Non-Blocking messages I get Protobuf, but what is gRPC ?

Slide 58

Slide 58 text

Authentification (per call, and TLS for trusted services) I get Protobuf, but what is gRPC ?

Slide 59

Slide 59 text

Cancellation and timeout handling I get Protobuf, but what is gRPC ?

Slide 60

Slide 60 text

Smart retries with backoff I get Protobuf, but what is gRPC ?

Slide 61

Slide 61 text

Error handling with standardized status codes I get Protobuf, but what is gRPC ?

Slide 62

Slide 62 text

Lameducking for graceful shutdowns I get Protobuf, but what is gRPC ?

Slide 63

Slide 63 text

A huge ecosystem

Slide 64

Slide 64 text

A huge ecosystem Used by Google, Lyft, Uber, Square, Netflix, CoreOS, Docker, Cockroachdb, Cisco, Juniper Networks…

Slide 65

Slide 65 text

A huge ecosystem Supported by nginx, kubernetes, envoy, etcd, istio…

Slide 66

Slide 66 text

A huge ecosystem A lot of middlewares available

Slide 67

Slide 67 text

A huge ecosystem A HTTP+JSON interface available

Slide 68

Slide 68 text

A new service is created protos monorepo crypto gRPC logging gRPC email gRPC sms gRPC storage gRPC billing gRPC service discovery ML gRPC

Slide 69

Slide 69 text

And for the front-end?

Slide 70

Slide 70 text

How does a restaurant expose services to a client?

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

GraphQL

Slide 73

Slide 73 text

A request example (developer.github.com/v4/explorer)

Slide 74

Slide 74 text

dashboard CLI API gateway mobile app GraphQL adapter protos monorepo crypto gRPC gRPC logging gRPC email gRPC sms gRPC storage gRPC billing gRPC service discovery gRPC REST

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Keep in mind that there's no silver bullet

Slide 77

Slide 77 text

This technologies allow you to create a factory of products / services

Slide 78

Slide 78 text

Thank you! Questions?