Microservices
vol.1.2.9
by Tomasz Tomczyk
Monolit -> Microservices
Decomposition
● Decompose by business capability
○ A business capability often corresponds to a business object, e.g.
■ product module -> product service
■ order module -> order service
● Decompose by subdomain
○ Define services corresponding to DDD subdomains. microservices.io
Data
● Database per Service
○ Event-driven architecture
○ Saga pattern
microservices.io
Deployment
● Multiple Services per host
● Single Service per host
○ Service per Container
○ Service per VM
microservices.io
Testing
● Service Integration Contract Test
○ Consumer knows:
■ what endpoints can use
■ what input do the endpoints take
■ what does the output look like.
● Service Component Test
○ Test a service in isolation. microservices.io
Observability
● Logging
○ centralized
○ not only errors (e.g. user activities)
● Monitoring
○ centralized
○ push/pull systems
● Tracing
○ unique request identity
● Visualization
Communication
Other system try to communicate with
microservice
● Directly connecting the front-end to
the microservices
● API gateway
○ BFF
○ protocol translations
unikow.github.io
Communication - Discovery
● Service registry
○ self registration
○ 3rd party registration
● Examples
○ Eureka - Netflix (sr),
Apache Zookeeper, Consul
auth0.com
auth0.com
Communication - Discovery
Network locations of the services are not
fixed.
● Client-side discovery
○ use smart HTTP client
● Server-side discovery
○ API Gateway (Router)
○ clear HTTP client
auth0.com
auth0.com
Communication - Style
Communication between our microservices
● Messaging (asynchronous)
● Remote Procedure Invocation (synchronous)
Communication - Circuit Breaker
Errors when one service is
unavailable
On failure strategy
● return default/cached data
● return error to caller
callistaenterprise.se
Cross-cutting concerns
● Microservice Chassis
● Externalized configuration
apprize.info
Security
● Access Token
○ The API Gateway authenticates the request
and passes an access token (e.g. JSON Web
Token)
microservices.io
UI
● Server-side page fragment composition
○ return rendered view parts
● Client-side UI composition
○ return response asjson
microservices.io
End ...

Microservices architecture

Editor's Notes

  • #3 Scaling monolit application can be challenging on module makes a lot of I/O operation the others are incredibly expensive from a CPU and others need a lot of memory
  • #4 Scaling monolit application can be challenging on module makes a lot of I/O operation the others are incredibly expensive from a CPU and others need a lot of memory
  • #13 Interaction styles: one-to-one - synchronous (Request/Reply) one-to-one - asynchronous (one way notification, request/async response) one-to-many - synchronous ( - ) one-to-many - asynchronous (publish/subscribe, publish/async response) Example. client publish event: give me information about product (async) subscribers receive information about product
  • #15 Podczas uruchamiania usługa odczytuje konfigurację ze źródła zewnętrznego, np. Zmienne środowiskowe systemu operacyjnego itp.