Integration of Microservices

What is microservice

  • is relatively small
  • can be developed and deployed independently
  • Ideally, each service should have only a small set of responsibilities (SRP)
  • Opposite to monolithic application

MOSi, POSi, Weather API, Warning text service, ....

Monolith is evil and only right way is microservice, which is one process written in any language.

Monolith advantages

  • One change in one commit
  • Easier to test functionality
  • No compatibility issues and dependencies
  • Deployment and rollback is simple

Integration

  • Direct client-to-microservice communication
  • API Gateway (Facade)
  • Service discovery
  • Database per service
  • Events sourcing
  • Deployment

Direct client to microservice communication

Pro

  • Easy to implement

Cons

  • Only HTTP protocol
  • Too many connections - slow
  • Difficult to refactor microservices - merging, splitting

API Gateway

Pros

  • encapsulate internal structure
  • simplify client code
  • auth, cache

Cons

  • another component
  • development bottleneck

Types

  • One for all clients
  • One for mobile, one for desktop, one for web

MeteoGroup

  • RoadMaster - Backed for Frontend
  • Weather API (access to MOSi, POSi)

Service discovery

  • Client side service discovery

Service Discovery

Client

Service

  • Server side service discovery

Service Discovery

Load Balancer

Service

Client

Service discovery in MG

Service Discovery

(Consul)

Load Balancer

Service A

Client

Service A

manifest.toml

manifest.toml

Database per service

Service A

Database

MySQL

Service B

Database

MongoDB

Pros

  • Loosely coupled
  • Best suited database for every service

Cons

  • Business transactions are harder to implement
  • Joining data is challenging
  • Complexity - managing SQL and NonSQL databases

 

"Database per service" doesn't mean a database SERVER per service

Event sourcing

Rather than persisting an object in its current state, event sourcing instead writes an immutable log of deltas (domain events) to the database

App

Event

Event

Event Store

Materialized View

Event

Event

External

Systems

Deployment

Multiple services per Host

Service per Host

Host

Service A

Service B

Service C

Service per VM

VM

Service A

VM

Service B

Service per Container

Container

Service A

Container

Service B

Host

Deployment in MG

Service per Container

Container

Service A

Container

Service A

Docker Host

Container

Service B

  • Marathon
    • Check app (running, stopped)
  • Grafana
    • Check resources (cpu, memory, ...)
  • Kibana
    • Check application logs

Q&A

deck

By Milan Hradil

deck

  • 501