Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

Arquitetura

Microservices

A A
Service Service
P P
Private I A I B
Network

Logs
DB DB
Port 8080 API
Gateway

IDs

A A
Service Service
P P
I
C I D

DB DB

Eureka Server Config Server


Service
B

message via message via


event A
Service event Service P
A C I

reques response
t

Service
D
message via
command

Broker
Service
E
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Arquitetura
Microservices

A A
Service Service
P P
Private I A I B
Network

Logs
DB DB
Port 8080 API
Gateway

IDs

A A
Service Service
P P
I
C I D

DB DB

Eureka Server Config Server


1° passo: Registry

A A
Eureka
Service Eureka
Service
P P
I Client
A Client
B
I

DB DB

Eureka Server

@brito_michelli
#decoderweek youtube.com/michellibrito
2° passo: Discovery

A
A A P
Service
Service Service
P P I B
I A B
I

DB DB

Eureka Server

@brito_michelli
#decoderweek youtube.com/michellibrito
2° passo: Discovery

request
A
A A P
Service
Service Service
P P I B
I A B
I
response

DB DB

Eureka Server

@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
request

Circuit Breaker
A A
Service Service
P P
I A B
I

DB DB

Estados: CLOSED, OPEN e HALF_OPEN

Métodos fallbacks e fluxos alternativos


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Arquitetura
Microservices

A A
Service Service
P P
Private I A I B
Network

Logs
DB DB
Port 8080 API
Gateway

IDs

A A
Service Service
P P
I
C I D

DB DB

Eureka Server Config Server


A
Service
P
I A

DB

A Service
P
I
B

DB
A
Service
P
Private I A
Network

DB
Port 8080 API
Gateway

A Service
P
I
B

DB
Eureka Server
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
A
Service
P
Private
I A
Network

DB
Port 8080 API A
P API Composer
Gateway I

A Service
P
I
B

DB
Eureka Server
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Arquitetura
Microservices

A A
Service Service
P P
Private I A I B
Network

Logs
DB DB
Port 8080 API
Gateway

IDs

A A
Service Service
P P
I
C I D

DB DB

Eureka Server Config Server


A A
Config
Service Config
Service
P P
I Client
A Client
B
I

DB DB

Config Server

@brito_michelli
#decoderweek youtube.com/michellibrito
A A
Service Service
P P
I A B
I

DB DB

Config Server

@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Service message message Service
A B

DB Broker DB

@brito_michelli
#decoderweek youtube.com/michellibrito
Service
B

Service
C
Service message message
Mediator
A

message Service
Broker
D

Broker

@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Prós
GET user
Isolamento de
responsabilidade do produtor
do evento
Service
B
Atenção
Pode gerar um bombardeio
de consultas no produtor do
UPDATE user evento
event notification DB
phoneNumber A Service phoneNumber changed
P
I A
sendNotification()

DB Broker

Service
updatePhoneNumber()
c
Notificação através de um
evento, onde os serviços que
precisam processar esse
DB evento devem recorrer ao
serviço primário para obter o
estado atual do recurso.
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Prós
GET user

Melhor performance

Service Maior disponibilidade


B

Atenção
User Table
UPDATE user
event state transfer DB Replicação dos dados
phoneNumber A Service uuid
new phoneNumber
P fullName
A phoneNumber
I sendNotification()
status
Consistência Eventual
updatePhoneNumber() email

User Document
{
DB uuid Broker
fullName
cpf Service
updatePhoneNumber() phoneNumber
status
c
email Transferência de estado entre
birthDate
address{
serviços através de eventos.
street
number User Table
city DB
cep uuid
state fullName
complement email
}
}
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Service Service Service
A B C

Transação Local Transação Local Transação Local


DB DB DB

@brito_michelli
#decoderweek youtube.com/michellibrito
1° case

Production
Service
order event
channel

createTicket()
POST new
order A DB confirmTicket()
Order
P completeTicket()
I Service
production event
channel

createOrder()
DB confirmOrder()

completeOrder() Payment
Service
payment event
channel

makePayment()
DB
Broker
2° case

Production
Service
order event
channel

createTicket()
POST new
order A DB cancelTicket()
Order
P
I Service
production event
channel

createOrder()
DB cancelOrder()

Payment
Service
payment event
channel

makePayment()
DB
Broker
1° case

Production
Service
production
command channel

createTicket()
POST new
order A DB confirmTicket()
P Order completeTicket()
I Service
order
reply channel

Payment
Service
payment
command channel

makePayment()
DB
Broker
createOrder()

DB confirmOrder()

completeOrder()
2° case

Production
Service
production
command channel

createTicket()
POST new
order A DB cancelTicket()
P Order
I Service
order
reply channel

Payment
Service
payment
command channel

makePayment()
DB
Broker
createOrder()

DB cancelOrder()
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
Arquitetura
Microservices

A A
Service Service
P P
Private I A I B
Network

Logs
DB DB
Port 8080 API
Gateway

IDs

A A
Service Service
P P
I
C I D

DB DB

Eureka Server Config Server


A A
Service Service
P P
Log INFO I A B Log INFO
I
Log INFO Log INFO
Log INFO Log INFO
Log WARN Log WARN
Log INFO Log INFO
Log INFO DB Log INFO
DB
Log ERROR Log INFO
Log ERROR Log INFO
Log ERROR Log INFO
Log INFO
Log INFO
Log WARN
Log ERROR

Logs
request request
A A
Service Service
P P
I A B
I
response response

DB DB

Tempo Total Request = A + B

@brito_michelli
#decoderweek youtube.com/michellibrito
request request
A A
Service Service
P P
I A B
I
response response

DB DB

Tempo Total Request = A + B

Identificadores Trace ID

@brito_michelli
#decoderweek youtube.com/michellibrito
request request
A A
Service Service
P P
I A B
I
response response

DB DB

Tempo Total Request = A + B

Identificadores Span ID

@brito_michelli
#decoderweek youtube.com/michellibrito
A A
Service Service
P P
I A B
I

DB DB

IDs
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
1 - Service Registry / Discovery Pattern 6 - Broker Pattern e Mediator Pattern

2 - Circuit Breaker Pattern 7 - Event Notification Pattern

3 - API Gateway Pattern 8 - Event-Carried State Transfer Pattern

4 - API Composition Pattern 9 - Saga Pattern (Coreografia versus Orquestração)

5 - Externalized Configuration Pattern 10 - Distributed Tracing e Log Aggregation Pattern


@brito_michelli
#decoderweek youtube.com/michellibrito
@brito_michelli
#decoderweek youtube.com/michellibrito

You might also like