Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices & Go - GOTO Copenhagen 2016

mattheath
October 04, 2016

Microservices & Go - GOTO Copenhagen 2016

mattheath

October 04, 2016
Tweet

More Decks by mattheath

Other Decks in Technology

Transcript

  1. Microservices & Go
    Matt Heath, Monzo

    View Slide

  2. View Slide

  3. Hi, I’m Matt
    @mattheath

    View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. monoliths
    traditional dev

    View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. ?

    View Slide

  18. Application

    View Slide

  19. Application
    Database

    View Slide

  20. Application
    Database

    View Slide

  21. Application
    Databases

    View Slide

  22. Application
    Databases
    Search

    View Slide

  23. Application
    Databases
    Search
    Caching

    View Slide

  24. Application
    Databases
    Search
    Caching
    CAT GIFS

    View Slide

  25. ALL
    HAIL
    THE
    MONOLITH

    View Slide

  26. View Slide

  27. Application
    Databases
    Search
    Caching
    CAT GIFS

    View Slide

  28. APPLICATION
    Application

    View Slide

  29. View Slide

  30. View Slide

  31. Single Responsibility
    Principle

    View Slide

  32. Bounded Context

    View Slide

  33. Well defined
    Interfaces

    View Slide

  34. Composability

    View Slide

  35. View Slide

  36. Simple

    View Slide

  37. Lightweight
    Concurrency

    View Slide

  38. // Blocking
    handleRequest()

    View Slide

  39. // Runs concurrently
    // in a goroutine
    go handleRequest()

    View Slide

  40. Go Routines

    View Slide

  41. Channels

    View Slide

  42. Static Linking

    View Slide

  43. View Slide

  44. View Slide

  45. monzo/typhon

    View Slide

  46. Service
    Service

    View Slide

  47. Service
    Service
    Message Bus

    View Slide

  48. Service
    Service
    Message Bus Request Queue

    View Slide

  49. Service
    Service
    Message Bus
    Service
    Service
    Request Queue
    - Service Discovery
    - Load Balancing

    View Slide

  50. Service
    Service
    Message Bus
    Service
    Service
    Pull
    Request Queue

    View Slide

  51. Service
    Service
    Message Bus
    Service
    Service

    View Slide

  52. 0
    40
    80
    160
    120
    Feb
    2015
    Oct
    2016

    View Slide

  53. Service
    Service
    Message Bus
    Service
    Service
    Client library
    Server library

    View Slide

  54. Service
    Service Service
    Service
    HTTP
    HTTP

    View Slide

  55. Service Discovery
    Load Balancing
    Timeouts and Expirations
    Retries
    Rate Limiting
    Connection Pooling
    Circuit Breaking
    Failure Detection
    Metrics and Tracing
    Interrupts
    Context Propagation

    View Slide

  56. Service
    Service Service
    Service
    HTTP
    HTTP
    ?

    View Slide

  57. Service
    Service Service
    Service
    HTTP
    HTTP
    linkerd

    View Slide

  58. Service Discovery
    Load Balancing
    Timeouts and Expirations
    Retries
    Rate Limiting
    Connection Pooling
    Circuit Breaking
    Failure Detection
    Metrics and Tracing
    Interrupts
    Context Propagation

    View Slide

  59. Load Balancer

    View Slide

  60. Load Balancer
    HTTP API & Routing Layer

    View Slide

  61. Load Balancer
    HTTP API & Routing Layer
    API

    Service

    View Slide

  62. View Slide

  63. /webhooks —-> Webhook API

    View Slide

  64. Load Balancer
    HTTP API & Routing Layer
    Webhook

    API

    View Slide

  65. Auth

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API

    View Slide

  66. Auth

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API
    Database

    View Slide

  67. Database
    Auth

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API
    Database

    View Slide

  68. External
    Provider
    Database
    Auth

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API
    Database

    View Slide

  69. type Service func(req Request) Response

    View Slide

  70. router.GET("/", List)
    router.POST("/", Register)
    router.DELETE("/:id", Deregister)

    View Slide

  71. Making our
    service reliable

    View Slide

  72. + =

    View Slide

  73. View Slide

  74. Webhook

    Service
    Webhook

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API

    View Slide

  75. Webhook

    Service
    Webhook

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API

    View Slide

  76. Webhook

    Service
    Webhook

    Service
    Webhook

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API

    View Slide

  77. Webhook

    Service
    Webhook

    Service
    Webhook

    Service
    Webhook

    Service
    Load Balancer
    HTTP API & Routing Layer
    Webhook

    API
    Slow or

    Errors

    View Slide

  78. Event Driven
    Architecture

    View Slide

  79. Service
    A
    Service
    B
    Load Balancer
    HTTP API & Routing Layer
    API
    Service

    View Slide

  80. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    HTTP API & Routing Layer

    View Slide

  81. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    HTTP API & Routing Layer

    View Slide

  82. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    HTTP API & Routing Layer
    Service
    C
    Service
    D
    Service
    E

    View Slide

  83. Context
    Propagation

    View Slide

  84. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

  85. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

  86. 8096820c-3b7b-47ec-bce6-1c239252ab40

    View Slide

  87. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

  88. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

  89. package context
    type Context interface {
    Deadline() (deadline time.Time, ok bool)
    Done() Err() error
    Value(key interface{}) interface{}
    }

    View Slide

  90. package context
    type Context interface {
    Deadline() (deadline time.Time, ok bool)
    Done() Err() error
    Value(key interface{}) interface{}
    }

    View Slide

  91. package context
    type Context interface {
    Deadline() (deadline time.Time, ok bool)
    Done() Err() error
    Value(key interface{}) interface{}
    }

    View Slide

  92. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

  93. api
    api
    api.customer
    api.customer
    service.customer
    service.customer
    SEND
    RECV
    SEND
    RECV
    RECV
    SEND
    RECV
    SEND

    View Slide

  94. api api.customer service.customer
    SEND
    RECV
    SEND
    RECV
    RECV
    SEND
    RECV
    SEND
    phosphor

    View Slide

  95. View Slide

  96. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View Slide

  97. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View Slide

  98. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View Slide

  99. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View Slide

  100. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View Slide

  101. View Slide

  102. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View Slide

  103. View Slide

  104. View Slide

  105. View Slide

  106. View Slide

  107. Small
    Simple
    Easy to learn

    View Slide

  108. Concurrency
    Channels

    View Slide

  109. Downsides?

    View Slide

  110. Starting with
    Microservices?

    View Slide

  111. Thanks!
    @mattheath
    @monzo

    View Slide

  112. ATM: Thomas Hawk

    Bank of Commerce: ABQ Museum Archives
    IBM System/360: IBM
    Absorbed: Saxbald Photography
    Go Gopher: Renee French
    Credits

    View Slide

  113. View Slide