Microservices

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Learning

Microservices Learning

Overview

An application based on microservices is composed of small, highly decoupled, mostly autonomous components, that are built to offer a specific (mostly business) functionality. A cloud-native application is composed of multiple microservices that communicated through shared infrastructure, in most cases over HTTP/REST. The microservices architecture provides two major advantages: various components can be developed, deployed, monitored, and troubleshot independently, on a service-by-service basis, rather than dealing with the entire application. The second advantage is that a specific layer can be scaled independently by other layers. The underlying infrastructure can also be provisioned and changed independently and faster.

James Lewis and Martin Fowler definition: Microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API.

Use Cases

A situation when we may benefit from splitting an application into separate services is when:

  • Logic is loosely coupled
  • Data models are different
  • Data is generally independent

Service Discovery

Service discovery is letting microservices know about each other in a dynamic environment. Service discovery addresses discovering the instances of a particular service, adding and removing service instances and handling the situation when a service instance becomes unresponsive.

In most cases, the service discovery function is implemented with a service registry.

Each service can either register itself, or use some library or tool to automatically register on startup. Once the service is registered, it is being monitored via health checks to ensure that is available.

There is client-side service discovery, where the dependent service connects to the registry and pulls targets. The downside is that this makes the service logic more complex, and also burdens it with load balancing duties. There is then server-side service discovery, where the dependent service sends requests into a load balancer. The load balancer interacts with the registry and becomes informed on possible targets. The load balancer does the load balancing.

Service Heath Monitoring

Synchronous Communication

Asynchronous Communication

Data Storage

Deployment

Unit and Integration Testing

Observability

Observability