liveBook · Manning

Provider

As explained in Microservices Patterns, Second Edition

A provider service is a service that owns some of the data returned by a distributed query and exposes that data through an API.

A provider service owns some of the data needed by a distributed system query. Its role depends on the query design: it can expose service queries through an API or publish data-change events for a separate query view. section 12.2.1 section 13.2.1

In API composition, an API composer calls each provider synchronously, using mechanisms such as REST or gRPC, and combines the results. Feasibility depends on where data resides and whether providers’ APIs and databases support the required queries. Even when the data is available, joining large datasets in memory can be inefficient. section 12.2.1

Figure 12.5 The API composition pattern consists of an API composer and two or more provider services. The API composer implements a query by querying the providers via their APIs and combining the results.
ApiCompositionBasedQueryBigPicture

The diagram shows how a composer queries provider services and combines their responses. section 12.2.1

Each synchronous provider call adds a potential source of failure and latency. Provider proxies can use circuit breakers, time limiters and bulkheads; carefully designed fallbacks and concurrent calls can improve resilience and performance. Results from separate provider databases can nevertheless be inconsistent when data changes during the query. section 12.3.3 section 12.2.4

In CQRS, providers publish events when their data changes. A view service consumes those events and maintains a query-oriented copy, so queries need not call providers at runtime. This shifts work to event publishing and view maintenance: contracts must be designed and evolved, consumers must handle duplicates and ordering, and the view is eventually consistent. Reliable publishing can use a transactional outbox to publish events in the same transaction as the database update. section 13.2.1 section 13.2.3

Order queries

A findOrder() query uses a composition service and four providers; all five must be available for a complete result. For findOrderHistory(), an order-history view instead subscribes to events from four providers and stores joined data for efficient querying. section 12.3.3 section 13.2.1

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines provider responsibilities and explains query feasibility, resilience mechanisms, event publishing, and coordination costs.
Examples
Uses order and order-history queries involving four provider services to contrast synchronous composition with an event-maintained view.
What you can do after
Evaluate provider responsibilities and trade-offs when choosing between synchronous query composition and event-maintained views.
How it connects
Connects providers to API composition, synchronous communication, CQRS, transactional outbox, and eventual consistency.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.