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

Building a Bank with Go - QCon London March 2017

Building a Bank with Go - QCon London March 2017

Traditionally applications have been built as monoliths; single applications which become larger and more complex over time, which limit our ability to react to change. An example of this is the banking industry where mergers and acquisitions between banks have lead to a patchwork of different systems & technologies that cost billions of dollars per year to maintain. As a result, the pace of innovation in the banking industry has slowed to a crawl. At Monzo we're building a new kind of bank backed by a microservice platform written in Go. In this talk we'll look at why Go is perfectly suited to this style of architecture, the language features that make it particularly attractive to high volume, low latency, distributed applications, and how easy it is to adopt into existing systems and organisations.

67f4a8f2a209a38d7242829947b26ba3?s=128

mattheath

March 07, 2017
Tweet

Transcript

  1. Building a Bank with Go Matt Heath, Monzo

  2. Hi, I’m Matt @mattheath

  3. None
  4. None
  5. monoliths traditional dev

  6. A UK banking licence is authorised by the PRA and

    regulated by the PRA and FCA1, allowing deposit- taking and balance sheet lending. Once granted, it allows firms to passport across Europe, accessing This is followed by a “mobilisation” phase during which final capital is raised and IT systems are completed, before launching to the public. We received a UK banking licence in August 2016! FEB 2015 JAN 2016 JAN 2017 MAR FEB FEB APR MAR MAR APR MAY JUN JUL MAY APR JUN MAY JUL JUN AUG JUL SEP AUG NOV SEP DEC NOV DEC PRE APPLICATION APPLICATION MOBILISATION LAUNCH LICENCE WITH RESTRICTIONS 50K MAX DEPOSIT WE ARE HERE
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. ?

  16. Application

  17. Application Database

  18. Application Database

  19. Application Databases

  20. Application Databases Search

  21. Application Databases Search Caching

  22. Application Databases Search Caching CAT GIFS

  23. ALL HAIL THE MONOLITH

  24. None
  25. Application Databases Search Caching CAT GIFS

  26. APPLICATION Application

  27. None
  28. None
  29. Single Responsibility Principle

  30. Bounded Context

  31. Well defined Interfaces

  32. None
  33. Why Go? Memory Managed Statically Typed Excellent Concurrency Perfect for

    simple, small, network services
  34. Lightweight Concurrency

  35. Goroutines

  36. // Blocking function call handleRequest()

  37. // Function runs concurrently go handleRequest()

  38. package main func main() { go handleRequest() // … }

  39. package main func main() { go handleRequest() // … }

    main
  40. package main func main() { go handleRequest() // … }

    handleRequest main
  41. "Do not communicate by sharing memory; instead, share memory by

    communicating." - Effective Go
  42. Channels

  43. None
  44. None
  45. None
  46. None
  47. Simplicity

  48. Static Linking Stdlib etc

  49. 0 40 80 160 120 Feb 2015 Mar 2017 200

    Number of services
  50. None
  51. None
  52. monzo/typhon

  53. Service Service

  54. Service Service Transport

  55. Service Service Transport Service Service

  56. Service Service Transport Service Service Client library Server library

  57. Service Service Service Service HTTP HTTP

  58. Service Discovery Load Balancing Timeouts and Expirations Retries Rate Limiting

    Connection Pooling Circuit Breaking Failure Detection Metrics and Tracing Interrupts Context Propagation
  59. Service Service Service Service HTTP HTTP ?

  60. Service Service Service Service HTTP HTTP linkerd

  61. Service Discovery Load Balancing Timeouts and Expirations Retries Rate Limiting

    Connection Pooling Circuit Breaking Failure Detection Metrics and Tracing Interrupts Context Propagation
  62. Load Balancer

  63. Load Balancer HTTP API & Routing Layer

  64. Load Balancer HTTP API & Routing Layer API
 Service

  65. None
  66. /webhooks —-> Webhook API

  67. Load Balancer HTTP API & Routing Layer Webhook
 API

  68. Auth
 Service Webhook
 Service Load Balancer HTTP API & Routing

    Layer Webhook
 API
  69. Auth
 Service Webhook
 Service Load Balancer HTTP API & Routing

    Layer Webhook
 API Database
  70. Database Auth
 Service Webhook
 Service Load Balancer HTTP API &

    Routing Layer Webhook
 API Database
  71. External Provider Database Auth
 Service Webhook
 Service Load Balancer HTTP

    API & Routing Layer Webhook
 API Database
  72. type Service func(req Request) Response

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

  74. Making our service reliable

  75. + = ❤

  76. None
  77. Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer HTTP API

    & Routing Layer Webhook
 API
  78. Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer HTTP API

    & Routing Layer Webhook
 API
  79. Webhook
 Service Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer

    HTTP API & Routing Layer Webhook
 API
  80. Webhook
 Service Webhook
 Service Webhook
 Service Webhook
 Service Load Balancer

    HTTP API & Routing Layer Webhook
 API Slow or
 Errors
  81. Event Driven Architecture

  82. Service A Service B Load Balancer HTTP API & Routing

    Layer API Service
  83. API Service Service A Service B Load Balancer HTTP API

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

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

    & Routing Layer Service C Service D Service E
  86. Context Propagation

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

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

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

  90. api api api.customer api.customer service.customer service.customer

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

  92. package context type Context interface { Deadline() (deadline time.Time, ok

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

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

    bool) Done() <-chan struct{} Err() error Value(key interface{}) interface{} }
  95. api api api.customer api.customer service.customer service.customer

  96. api api api.customer api.customer service.customer service.customer SEND RECV SEND RECV

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

    SEND phosphor
  98. None
  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
  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
  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
  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
  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
  104. None
  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
  106. None
  107. None
  108. Perfect for
 microservice architectures

  109. Concurrency:
 Goroutines Channels

  110. Small Simple Easy

  111. Thanks! @mattheath @monzo