Sobes.tech
Senior

How to organize data transfer from three microservices (products, prices, orders) in a microservice architecture?

sobes.tech AI

Answer from AI

In microservice architecture, to transmit data to the client from multiple microservices (e.g., products, prices, orders), one of the following approaches is often used:

  1. API Gateway / Aggregator

    • A separate service (API Gateway) is created, which receives requests from the client.
    • It communicates with microservices for products, prices, and orders, gathers data, and forms a single response.
    • The client receives aggregated data with a single request.
  2. Backend for Frontend (BFF)

    • A specialized service tailored for a specific client (web, mobile).
    • Performs aggregation and transformation of data from different microservices.
  3. GraphQL

    • Using a GraphQL server that internally communicates with various microservices.
    • The client requests exactly the data it needs in one request.
  4. Event-driven / CQRS

    • Microservices publish events about changes.
    • A specialized service collects and aggregates data into a separate storage for quick reading.

The choice depends on performance requirements, complexity, and data update frequency. In practice, API Gateway or BFF are often used for simplicity and centralized management.

How to organize data transfer from three… - sobes.tech