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

Building Microservice Architectures with Go - Yow! 2015

mattheath
December 11, 2015

Building Microservice Architectures with Go - Yow! 2015

Presented at Yow! 2015 in Melbourne, Brisbane and Sydney
http://yowconference.com.au/

mattheath

December 11, 2015
Tweet

More Decks by mattheath

Other Decks in Programming

Transcript

  1. Building Microservice
    Architectures with Go
    Matt Heath, Mondo
    #yow2015

    View Slide

  2. @mattheath

    View Slide

  3. View Slide

  4. View Slide

  5. 1895

    View Slide

  6. monoliths
    traditional dev

    View Slide

  7. 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. DATABASE
    APPLICATION

    View Slide

  18. DATABASE
    APPLICATION

    View Slide

  19. DATABASE
    DATABASES
    APPLICATION

    View Slide

  20. DATABASE
    DATABASES
    APPLICATION
    SEARCH

    View Slide

  21. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH

    View Slide

  22. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH
    CAT GIFS

    View Slide

  23. ALL
    HAIL
    THE
    MONOLITH

    View Slide

  24. DO NOT WANT

    View Slide

  25. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH
    CAT GIFS

    View Slide

  26. APPLICATION

    View Slide

  27. View Slide

  28. View Slide

  29. Why Microservices
    at Mondo?

    View Slide

  30. Single Responsibility
    Principle

    View Slide

  31. Bounded Context

    View Slide

  32. Well defined
    Interfaces

    View Slide

  33. Composability

    View Slide

  34. Why not start with
    Microservices?

    View Slide

  35. LOAD BALANCER

    View Slide

  36. LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  37. TRANSPORT
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  38. SERVICE SERVICE SERVICE
    TRANSPORT
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  39. SERVICE SERVICE SERVICE
    TRANSPORT
    DATABASE DATABASE DATABASE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  40. SERVICE SERVICE SERVICE
    TRANSPORT
    DATABASE DATABASE DATABASE
    LOAD BALANCER
    DATACENTRE n
    HTTP API & ROUTING LAYER

    View Slide

  41. SERVICE SERVICE SERVICE
    TRANSPORT
    DATABASE DATABASE DATABASE
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    DATACENTRE n

    View Slide

  42. View Slide

  43. Simple
    Static typing
    Static linking

    View Slide

  44. Concurrency
    Interfaces

    View Slide

  45. stdlib
    eg. Networking

    View Slide

  46. Go Kit
    micro
    gRPC
    Kite

    View Slide

  47. mondough/typhon
    mondough/mercury

    View Slide

  48. LOAD BALANCER

    View Slide

  49. LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  50. API
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  51. /webhooks —-> Webhook API

    View Slide

  52. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  53. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  54. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    DATABASE

    View Slide

  55. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    DATABASE
    DATABASE

    View Slide

  56. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    DATABASE
    DATABASE
    EXTERNAL
    PROVIDER

    View Slide

  57. Event Driven
    Architectures

    View Slide

  58. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  59. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View Slide

  60. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    SERVICE
    C
    SERVICE
    D
    E

    View Slide

  61. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    SERVICE
    C
    SERVICE
    D
    G
    E
    F

    View Slide

  62. ?
    ? ?
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    ?
    ?
    ??
    ?
    ?
    ?
    ?
    ?
    ?
    ?

    View Slide

  63. SERVICE

    View Slide

  64. Logic
    Handlers
    Storage
    SERVICE

    View Slide

  65. mercury
    Logic
    Handlers
    Storage
    SERVICE

    View Slide

  66. type Handler func(request) (response, error)

    View Slide

  67. type Transport interface {
    ...
    }

    View Slide

  68. type Transport interface {
    Listen(serviceName string, inbound chanStopListening(serviceName string) bool
    Respond(req request, resp response) error
    Send(req request, timeout time.Duration) (response, error)
    ...
    }

    View Slide

  69. type Transport interface {
    Listen(serviceName string, inbound chanStopListening(serviceName string) bool
    Respond(req request, resp response) error
    Send(req request, timeout time.Duration) (response, error)
    ...
    }

    View Slide

  70. mercury
    Logic
    Handlers
    Storage
    SERVICE

    View Slide

  71. mercury
    Logic
    Handlers
    Storage libraries
    SERVICE

    View Slide

  72. mercury
    Logic
    Handlers
    Storage libraries
    SERVICE
    Deployment
    Service Discovery
    Configuration
    Monitoring
    Authentication
    Authorisation
    Storage
    Circuit Breaking

    View Slide

  73. View Slide

  74. View Slide

  75. Scratch
    Images

    View Slide

  76. Statically
    Compiled

    View Slide

  77. Root CA
    Certs

    View Slide

  78. View Slide

  79. Dealing with
    Complexity

    View Slide

  80. Testing

    View Slide

  81. Load
    Failure
    Degradation

    View Slide

  82. Monitoring

    View Slide

  83. Monitor your
    Business Logic

    View Slide

  84. ♥ customers

    View Slide

  85. In-Band vs
    Out of Band

    View Slide

  86. type Checker func() (error, map[string]string)

    View Slide

  87. Distributed Tracing

    View Slide

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

    View Slide

  89. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

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

    View Slide

  91. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

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

    View Slide

  93. Context
    Propagation

    View Slide

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

    View Slide

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

    View Slide

  96. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View Slide

  97. api
    api
    api.customer
    api.customer
    service.customer
    service.customer
    SEND
    RECV
    SEND
    RECV
    RECV
    SEND
    RECV
    SEND

    View Slide

  98. mondough/phosphor

    View Slide

  99. api api.customer service.customer
    SEND
    RECV
    SEND
    RECV
    RECV
    SEND
    RECV
    SEND
    phosphor

    View Slide

  100. View Slide

  101. 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

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

  104. 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

  105. 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

  106. View Slide

  107. 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

  108. View Slide

  109. View Slide

  110. View Slide

  111. Small
    Simple
    Easy to learn

    View Slide

  112. Concurrency
    Interfaces
    Networking

    View Slide

  113. Downsides?

    View Slide

  114. Starting with
    Microservices?

    View Slide

  115. #yow2015
    Thanks!
    @mattheath
    @getmondo

    View Slide

  116. ATM: Thomas Hawk

    Bank of Commerce: ABQ Museum Archives
    IBM System/360: IBM
    Absorbed: Saxbald Photography
    Orbital Ion Cannon: www.rom.ac
    Go Gopher: Renee French
    Control Room: NASA
    ATM Failure: George Redgrave
    Credits

    View Slide