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 full-size slide

  2. monoliths
    traditional dev

    View full-size slide

  3. DATABASE
    APPLICATION

    View full-size slide

  4. DATABASE
    APPLICATION

    View full-size slide

  5. DATABASE
    DATABASES
    APPLICATION

    View full-size slide

  6. DATABASE
    DATABASES
    APPLICATION
    SEARCH

    View full-size slide

  7. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH

    View full-size slide

  8. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH
    CAT GIFS

    View full-size slide

  9. ALL
    HAIL
    THE
    MONOLITH

    View full-size slide

  10. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH
    CAT GIFS

    View full-size slide

  11. Why Microservices
    at Mondo?

    View full-size slide

  12. Single Responsibility
    Principle

    View full-size slide

  13. Bounded Context

    View full-size slide

  14. Well defined
    Interfaces

    View full-size slide

  15. Composability

    View full-size slide

  16. Why not start with
    Microservices?

    View full-size slide

  17. LOAD BALANCER

    View full-size slide

  18. LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  19. TRANSPORT
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  24. Simple
    Static typing
    Static linking

    View full-size slide

  25. Concurrency
    Interfaces

    View full-size slide

  26. stdlib
    eg. Networking

    View full-size slide

  27. Go Kit
    micro
    gRPC
    Kite

    View full-size slide

  28. mondough/typhon
    mondough/mercury

    View full-size slide

  29. LOAD BALANCER

    View full-size slide

  30. LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  31. API
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  32. /webhooks —-> Webhook API

    View full-size slide

  33. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  38. Event Driven
    Architectures

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  44. Logic
    Handlers
    Storage
    SERVICE

    View full-size slide

  45. mercury
    Logic
    Handlers
    Storage
    SERVICE

    View full-size slide

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

    View full-size slide

  47. type Transport interface {
    ...
    }

    View full-size slide

  48. type Transport interface {
    Listen(serviceName string, inbound chan<- request) error
    StopListening(serviceName string) bool
    Respond(req request, resp response) error
    Send(req request, timeout time.Duration) (response, error)
    ...
    }

    View full-size slide

  49. type Transport interface {
    Listen(serviceName string, inbound chan<- request) error
    StopListening(serviceName string) bool
    Respond(req request, resp response) error
    Send(req request, timeout time.Duration) (response, error)
    ...
    }

    View full-size slide

  50. mercury
    Logic
    Handlers
    Storage
    SERVICE

    View full-size slide

  51. mercury
    Logic
    Handlers
    Storage libraries
    SERVICE

    View full-size slide

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

    View full-size slide

  53. Scratch
    Images

    View full-size slide

  54. Statically
    Compiled

    View full-size slide

  55. Root CA
    Certs

    View full-size slide

  56. Dealing with
    Complexity

    View full-size slide

  57. Load
    Failure
    Degradation

    View full-size slide

  58. Monitor your
    Business Logic

    View full-size slide

  59. ♥ customers

    View full-size slide

  60. In-Band vs
    Out of Band

    View full-size slide

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

    View full-size slide

  62. Distributed Tracing

    View full-size slide

  63. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View full-size slide

  64. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View full-size slide

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

    View full-size slide

  66. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View full-size slide

  67. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View full-size slide

  68. Context
    Propagation

    View full-size slide

  69. package context
    type Context interface {
    Deadline() (deadline time.Time, ok bool)
    Done() <-chan struct{}
    Err() error
    Value(key interface{}) interface{}
    }

    View full-size slide

  70. package context
    type Context interface {
    Deadline() (deadline time.Time, ok bool)
    Done() <-chan struct{}
    Err() error
    Value(key interface{}) interface{}
    }

    View full-size slide

  71. api
    api
    api.customer
    api.customer
    service.customer
    service.customer

    View full-size slide

  72. api
    api
    api.customer
    api.customer
    service.customer
    service.customer
    SEND
    RECV
    SEND
    RECV
    RECV
    SEND
    RECV
    SEND

    View full-size slide

  73. mondough/phosphor

    View full-size slide

  74. api api.customer service.customer
    SEND
    RECV
    SEND
    RECV
    RECV
    SEND
    RECV
    SEND
    phosphor

    View full-size slide

  75. 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 full-size slide

  76. 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 full-size slide

  77. 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 full-size slide

  78. 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 full-size slide

  79. 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 full-size slide

  80. 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 full-size slide

  81. Small
    Simple
    Easy to learn

    View full-size slide

  82. Concurrency
    Interfaces
    Networking

    View full-size slide

  83. Starting with
    Microservices?

    View full-size slide

  84. #yow2015
    Thanks!
    @mattheath
    @getmondo

    View full-size slide

  85. 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 full-size slide