Manage microservices like a Chef

Manage microservices like a Chef

Be03847a223c7afbad30c4993ea61a6e?s=128

Mathieu Acthernoene

May 30, 2018
Tweet

Transcript

  1. Manage microservices like a Chef

  2. Mathieu Acthernoene @zoontek

  3. Microservices are awesome ✨

  4. Microservices are awesome ✨ Each service is an app implementing

    its own business logic service database SaaS 1 SaaS 2
  5. Microservices are awesome ✨ Separated by concern, easier to understand

    what's going on auth email sms …
  6. 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
  7. Microservices are awesome ✨ If one breaks, you don't have

    to reboot everything service 1 service 3 service 4
  8. Microservices are awesome ✨ Scales according to the service needs,

    not globally CPU intensive service RAM intensive service GPU intensive service
  9. Microservices are awesome ✨ Each service team is free to

    use the right tools service using couchDB service using JavaScript service using Golang
  10. But

  11. But

  12. Just as you think you're making microservices

  13. You might just not

  14. You are not building microservices when… #

  15. You are not building microservices when… # Changes needs to

    be synced service 1 service 1 change service 2
  16. Deploys needs to be synced You are not building microservices

    when… # service 1 service 1 deploy service 2
  17. 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
  18. They share a datastore You are not building microservices when…

    # service 1 database service 2
  19. 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 {}
  20. You just created a distributed monolith crypto REST logging REST

    email REST sms REST storage REST billing REST
  21. None
  22. Managing microservices is like managing a restaurant

  23. waiter REST sous-chef REST pastry chef REST wine waiter REST

    washer REST chef REST
  24. None
  25. How does a restaurant manage services?

  26. None
  27. The “simple” gateway solution crypto REST logging REST email REST

    sms REST storage REST billing REST gateway REST
  28. One interlocutor passing messages to the right services

  29. 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 …
  30. Latency caused by serialization / deserialization service 1 service 2

    API gateway decode JSON understand message create message encode JSON The REST / JSON gateway issues ⚠
  31. 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 ⚠
  32. 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 ⚠
  33. As JSON types are basic (JavaScript interop…), a documentation is

    mandatory The REST / JSON gateway issues ⚠
  34. How does a restaurant manage communication?

  35. None
  36. People working in the kitchen don't necessarily have the same

    mother tongue
  37. They don't force their coworkers to use their language

  38. Protobuf ↔

  39. Protobuf ↔ Created by, and for Google in 2001

  40. A binary format for typed exchanges Protobuf ↔

  41. Protobuf ↔ Generate clients for C++, Java, Python, Go, Ruby,

    C#, JS, ObjC, PHP, Dart…
  42. Offers backward compatibility for free Protobuf ↔

  43. Offers a JSON mapping Protobuf ↔

  44. Tooling and linters are available Protobuf ↔

  45. Allows RPC methods definition Protobuf ↔

  46. How to write a .proto file

  47. syntax = "proto3";

  48. package storage;

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

  50. option java_package = "com.scaleway.storage";

  51. 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]; }
  52. 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; }
  53. 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; }
  54. None
  55. I get Protobuf, but what is gRPC ? HTTP/2 clients

    for Protobuf messages transport
  56. Unaries, uni- and bi-directional streams I get Protobuf, but what

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

    gRPC ?
  58. Authentification (per call, and TLS for trusted services) I get

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

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

    gRPC ?
  61. Error handling with standardized status codes I get Protobuf, but

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

    gRPC ?
  63. A huge ecosystem

  64. A huge ecosystem Used by Google, Lyft, Uber, Square, Netflix,

    CoreOS, Docker, Cockroachdb, Cisco, Juniper Networks…
  65. A huge ecosystem Supported by nginx, kubernetes, envoy, etcd, istio…

  66. A huge ecosystem A lot of middlewares available

  67. A huge ecosystem A HTTP+JSON interface available

  68. A new service is created protos monorepo crypto gRPC logging

    gRPC email gRPC sms gRPC storage gRPC billing gRPC service discovery ML gRPC
  69. And for the front-end?

  70. How does a restaurant expose services to a client?

  71. None
  72. GraphQL

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

  74. 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
  75. None
  76. Keep in mind that there's no silver bullet

  77. This technologies allow you to create a factory of products

    / services
  78. Thank you! Questions?