0% found this document useful (0 votes)
278 views116 pages

Building Microservice Architectures With Go (PDFDrive)

The document discusses building microservice architectures using Go, highlighting the advantages such as the Single Responsibility Principle, bounded contexts, and well-defined interfaces. It also addresses the complexities of microservices, including deployment, service discovery, and monitoring. Additionally, it emphasizes the importance of concurrency, static typing, and the use of libraries like Go Kit and gRPC in developing microservices.

Uploaded by

Ouedraogo Jean
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
278 views116 pages

Building Microservice Architectures With Go (PDFDrive)

The document discusses building microservice architectures using Go, highlighting the advantages such as the Single Responsibility Principle, bounded contexts, and well-defined interfaces. It also addresses the complexities of microservices, including deployment, service discovery, and monitoring. Additionally, it emphasizes the importance of concurrency, static typing, and the use of libraries like Go Kit and gRPC in developing microservices.

Uploaded by

Ouedraogo Jean
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 116

Building Microservice

Architectures with Go
Matt Heath, Mondo

#yow2015
@mattheath
1895
monoliths
traditional dev
?
APPLICATION

DATABASE
APPLICATION

DATABASE
APPLICATION

DATABASES
DATABASE
APPLICATION

SEARCH
DATABASES
DATABASE
APPLICATION

SEARCH
DATABASES CACHE
DATABASE
APPLICATION

SEARCH
DATABASES CACHE
DATABASE
CAT GIFS
ALL
HAIL
THE
MONOLITH
DO NOT WANT
APPLICATION

SEARCH
DATABASES CACHE
DATABASE
CAT GIFS
APPLICATION
Why Microservices
at Mondo?
Single Responsibility
Principle
Bounded Context
Well defined
Interfaces
Composability
Why not start with
Microservices?
LOAD BALANCER
LOAD BALANCER
HTTP API & ROUTING LAYER
LOAD BALANCER
HTTP API & ROUTING LAYER

TRANSPORT
LOAD BALANCER
HTTP API & ROUTING LAYER

TRANSPORT

SERVICE SERVICE SERVICE


LOAD BALANCER
HTTP API & ROUTING LAYER

TRANSPORT

SERVICE SERVICE SERVICE

DATABASE DATABASE DATABASE


LOAD BALANCER
HTTP API & ROUTING LAYER

TRANSPORT

SERVICE SERVICE SERVICE

DATABASE DATABASE DATABASE

DATACENTRE n
LOAD BALANCER
HTTP API & ROUTING LAYER

TRANSPORT

SERVICE SERVICE SERVICE

DATABASE DATABASE DATABASE

DATACENTRE n
Simple
Static typing
Static linking
Concurrency
Interfaces
stdlib
eg. Networking
Go Kit
micro
gRPC
Kite
mondough/typhon
mondough/mercury
LOAD BALANCER
LOAD BALANCER
HTTP API & ROUTING LAYER
LOAD BALANCER
HTTP API & ROUTING LAYER

API
SERVICE
/webhooks —-> Webhook API
LOAD BALANCER
HTTP API & ROUTING LAYER

WEBHOOK
API
LOAD BALANCER
HTTP API & ROUTING LAYER

WEBHOOK
API

AUTH WEBHOOK
SERVICE SERVICE
LOAD BALANCER
HTTP API & ROUTING LAYER

WEBHOOK
API

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

WEBHOOK
API

AUTH WEBHOOK
DATABASE
SERVICE SERVICE

DATABASE
LOAD BALANCER
HTTP API & ROUTING LAYER

API
SERVICE EXTERNAL
PROVIDER

SERVICE SERVICE
DATABASE
A B

DATABASE
Event Driven
Architectures
LOAD BALANCER
HTTP API & ROUTING LAYER

API
SERVICE

SERVICE SERVICE
A B
LOAD BALANCER
HTTP API & ROUTING LAYER

API
SERVICE

SERVICE SERVICE
A B
LOAD BALANCER
HTTP API & ROUTING LAYER

API
SERVICE SERVICE
D

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

G
API
SERVICE SERVICE
D

SERVICE SERVICE
A B E
SERVICE
C F
LOAD BALANCER
HTTP API & ROUTING LAYER

? ??
?
? ?
?
?

? ? ? ?

? ?
SERVICE
Handlers

Logic

Storage

SERVICE
Handlers mercury

Logic

Storage

SERVICE
type Handler func(request) (response, error)
type Transport interface {
...
}
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)

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

...
}
Handlers mercury

Logic

Storage

SERVICE
Handlers mercury

Logic

Storage libraries

SERVICE
Deployment
Service Discovery
Handlers mercury Configuration
Monitoring
Logic
Authentication
Storage libraries Authorisation
SERVICE
Storage
Circuit Breaking
Scratch
Images
Statically
Compiled
Root CA
Certs
Dealing with
Complexity
Testing
Load
Failure
Degradation
Monitoring
Monitor your
Business Logic
♥ customers
In-Band vs
Out of Band
type Checker func() (error, map[string]string)
Distributed Tracing
api api.customer service.customer

api api.customer service.customer


api api.customer service.customer

api api.customer service.customer


8096820c-3b7b-47ec-bce6-1c239252ab40
api api.customer service.customer

api api.customer service.customer


api api.customer service.customer

api api.customer service.customer


Context
Propagation
package context

type Context interface {


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

type Context interface {


Deadline() (deadline time.Time, ok bool)
Done() <-chan struct{}
Err() error
Value(key interface{}) interface{}
}
api api.customer service.customer

api api.customer service.customer


api api.customer service.customer

SEND

RECV SEND
RECV
SEND
SEND RECV

RECV

api api.customer service.customer


mondough/phosphor
api api.customer service.customer

SEND

RECV SEND
RECV
SEND
SEND RECV

RECV

phosphor
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
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
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
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
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
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
Small
Simple
Easy to learn
Concurrency
Interfaces
Networking
Downsides?
Starting with
Microservices?
Thanks!
@mattheath
@getmondo

#yow2015
Credits
ATM: Thomas Hawk
IBM System/360: IBM
Absorbed: Saxbald Photography
Orbital Ion Cannon: www.rom.ac
Go Gophers: Renee French
Control Room: NASA
ATM Failure: George Redgrave

You might also like