How to Build a Scalable Reporting Service in a Microservice Architecture

To generate a user‑enriched order report in a microservice system, the article compares four approaches—direct DB access, REST data aggregation, batch pulling, and an event‑driven model—highlighting their trade‑offs in coupling, performance, scalability, and resilience, and recommends the event‑push solution.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How to Build a Scalable Reporting Service in a Microservice Architecture

Scenario Description

In a microservice architecture each service owns its own database, and Service A is not allowed to directly connect to Service B’s database.

Microservice diagram
Microservice diagram

There are two services: an order service and a user service.

The reporting requirement is to generate an order report that includes user information, which means data must be fetched from both services and joined.

Solution 1: Direct Database Connection

Direct DB connection diagram
Direct DB connection diagram

Connect directly to the order and user service databases, retrieve the needed data, and process it.

This is simple but breaks the microservice principle of isolation, and any change in database schema forces the reporting service to change, making it highly sensitive.

Solution 2: Data Aggregation via REST

REST aggregation diagram
REST aggregation diagram

Call the REST APIs of the two services to obtain the required data.

This avoids direct DB access but suffers from poor performance: the reporting service must frequently request the latest data, and as data volume grows the latency of all three services degrades.

Solution 3: Batch Data Pull

Batch pull diagram
Batch pull diagram

Create a dedicated database for the reporting service and use a scheduled job to batch‑pull data from the two services’ databases into its own store.

This improves performance but re‑introduces tight coupling and remains extremely sensitive to schema changes, although having its own database simplifies further processing.

Solution 4: Event‑Driven Push Model

Event push diagram
Event push diagram

When data tables in the order or user service change, an event is published to a message system (e.g., Kafka). The reporting service subscribes to relevant topics and writes the received data into its own database.

Benefits:

Loose coupling – business services and the reporting service have no direct API or DB calls.

Strong data consistency and near‑real‑time updates.

High performance – additional workers can be added to handle increased event throughput.

Excellent extensibility – new services only need to emit change events, enabling future analytics or additional reporting needs.

Source: Medium article

Final illustration
Final illustration
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

architectureMicroservicesKafkaData IntegrationEvent-drivenReporting
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.