TECHNOLOGY

Microservices Communication Patterns

Microservices Communication Patterns

Microservices Communication Patterns

This block of templates covers how microservices interact externally: with client applications, remote services, and so on.

API Gateway Pattern

The most obvious way to access microservices is to go directly from the client to the service. And it is quite possible to apply it in small projects. However, for enterprise-scale applications with a large number of microservices, the API Gateway pattern is recommended.

This pattern is based on using a gateway that sits between the client application and microservices, providing a single entry point for the client.

Depending on the specific purpose of using the pattern, the following types of it are sometimes distinguished:

  • Gateway Routing: The gateway is used as a reverse proxy, redirecting client requests to the appropriate service.
  • Gateway Aggregation: The gateway is used to fork a client request across multiple microservices and return aggregated responses to the client.
  • Gateway Offloading: The gateway solves end-to-end tasks common to services: authentication, authorization, SSL, logging, and so on.

The use of the pattern reduces the number of calls, ensures client independence from the protocols used in services: REST, AMQP, gRPC, and so on, and provides centralized management of end-to-end functionality. However, a gateway can become a single point of failure, requires careful monitoring, and can be a bottleneck in the system in the absence of scaling.

Backends For Frontends (BFF) Template

This pattern is a variant of the API Gateway pattern implementation. It also provides an extra layer between microservices and clients. Still, instead of a single entry point, it introduces multiple gateways for each client type: Web, Mobile, Desktop, and so on.

Using the pattern, you can add APIs tailored to the needs of each client, eliminating the need to store a lot of unnecessary settings in one place. But the pattern should not be used in cases where the difference in API requirements for different types of clients is negligible or the application itself is tiny: this will only lead to code duplication and an increase in the number of components.

User Interface Design Patterns

This group of templates offers solutions for displaying data from multiple microservices on a single page or UI screen.

Client-Side UI Composition Template

Using this template, HTML markup is generated and updated directly in the browser. Each screen/page of the user interface is split into chunks, the data received by various microservices. Each such piece is essentially a mini-application that can display and update its markup independently of the rest of the page.

Many modern frameworks like AngularJS and ReactJS help in implementing this pattern. They use the principle of single-page applications (Single-Page Application, SPA), allowing you to update a specific area of ​​the screen rather than the entire page.

Server-Side Page Fragment Composition Template

With this template, UI snippets are assembled on the server, and the client-side receives a fully assembled page, resulting in faster loading times. The build is usually performed by a separate service between the browser and the application servers: Nginx, Varnish, CDN.

Also Read: Analogs Are Inappropriate: Why Officials Do Not Want To Buy Russian Computers

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *