Microservices & GoMatt Heath, Monzo
View Slide
Hi, I’m Matt@mattheath
monolithstraditional dev
?
Application
ApplicationDatabase
ApplicationDatabases
ApplicationDatabasesSearch
ApplicationDatabasesSearchCaching
ApplicationDatabasesSearchCachingCAT GIFS
ALLHAILTHEMONOLITH
APPLICATIONApplication
Single ResponsibilityPrinciple
Bounded Context
Well definedInterfaces
Composability
Simple
LightweightConcurrency
// BlockinghandleRequest()
// Runs concurrently// in a goroutinego handleRequest()
Go Routines
Channels
Static Linking
monzo/typhon
ServiceService
ServiceServiceMessage Bus
ServiceServiceMessage Bus Request Queue
ServiceServiceMessage BusServiceServiceRequest Queue- Service Discovery- Load Balancing
ServiceServiceMessage BusServiceServicePullRequest Queue
ServiceServiceMessage BusServiceService
04080160120Feb2015Oct2016
ServiceServiceMessage BusServiceServiceClient libraryServer library
ServiceService ServiceServiceHTTPHTTP
Service DiscoveryLoad BalancingTimeouts and ExpirationsRetriesRate LimitingConnection PoolingCircuit BreakingFailure DetectionMetrics and TracingInterruptsContext Propagation
ServiceService ServiceServiceHTTPHTTP?
ServiceService ServiceServiceHTTPHTTPlinkerd
Load Balancer
Load BalancerHTTP API & Routing Layer
Load BalancerHTTP API & Routing LayerAPI Service
/webhooks —-> Webhook API
Load BalancerHTTP API & Routing LayerWebhook API
Auth ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook API
Auth ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook APIDatabase
DatabaseAuth ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook APIDatabase
ExternalProviderDatabaseAuth ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook APIDatabase
type Service func(req Request) Response
router.GET("/", List)router.POST("/", Register)router.DELETE("/:id", Deregister)
Making ourservice reliable
+ =❤
Webhook ServiceWebhook ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook API
Webhook ServiceWebhook ServiceWebhook ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook API
Webhook ServiceWebhook ServiceWebhook ServiceWebhook ServiceLoad BalancerHTTP API & Routing LayerWebhook APISlow or Errors
Event DrivenArchitecture
ServiceAServiceBLoad BalancerHTTP API & Routing LayerAPIService
APIServiceServiceAServiceBLoad BalancerHTTP API & Routing Layer
APIServiceServiceAServiceBLoad BalancerHTTP API & Routing LayerServiceCServiceDServiceE
ContextPropagation
apiapiapi.customerapi.customerservice.customerservice.customer
8096820c-3b7b-47ec-bce6-1c239252ab40
package contexttype Context interface {Deadline() (deadline time.Time, ok bool)Done() Err() errorValue(key interface{}) interface{}}
apiapiapi.customerapi.customerservice.customerservice.customerSENDRECVSENDRECVRECVSENDRECVSEND
api api.customer service.customerSENDRECVSENDRECVRECVSENDRECVSENDphosphor
API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apnsAPI card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
SmallSimpleEasy to learn
ConcurrencyChannels
Downsides?
Starting withMicroservices?
Thanks!@mattheath@monzo
ATM: Thomas Hawk Bank of Commerce: ABQ Museum ArchivesIBM System/360: IBMAbsorbed: Saxbald PhotographyGo Gopher: Renee FrenchCredits