Exploring Microservice Architecture Patterns: Aggregation, Sharing, Proxy, and Async Messaging
This article outlines four key microservice architecture patterns—aggregation, shared database, proxy (API gateway), and asynchronous messaging—detailing their advantages, drawbacks, and typical application scenarios to help architects choose the right approach for scalable, resilient systems.
Microservice Aggregation Pattern
Through an aggregation layer (aggregator), multiple microservices are called, their results combined, and a unified service is exposed to external clients.
Advantages
Simplifies client interaction: the client only communicates with the aggregation service, reducing client complexity.
Unified interface: the aggregation service provides a single API entry point, facilitating front‑end or external system calls.
Disadvantages
Single point of failure: if the aggregation service goes down, the entire request chain may be affected.
Performance bottleneck: the aggregation service must wait for all dependent services, potentially accumulating latency.
Increased complexity: the aggregation service must handle cross‑service data consistency and error handling.
Typical Use Cases
Scenarios where data from multiple microservices needs to be combined for presentation, such as front‑end aggregation APIs.
Microservice Shared Database Pattern
Multiple microservices share access to the same database or cache resources.
Advantages
Simple data access: services query the shared database directly without extra API calls.
Rapid implementation: suitable for migrating from a monolithic architecture to microservices while retaining the original database schema.
Transactional consistency: a shared database supports strong ACID transactions, fitting transactional requirements.
Disadvantages
Violates microservice autonomy: services become tightly coupled, hindering independent deployment and evolution.
Typical Use Cases
Transitional phase when converting a traditional monolith to microservices; not recommended for newly built microservices.
Microservice Proxy (API Gateway) Pattern
A proxy layer (e.g., API gateway) handles client requests, performing routing, authentication, rate limiting, etc., and forwards them to backend microservices, serving as a unified entry point.
Advantages
Flexible client call handling, reducing client complexity.
The proxy can perform protocol conversion, request aggregation, routing control, and other functions.
Disadvantages
Additional network hop introduces latency.
Complex proxy logic can be hard to maintain.
Microservice Asynchronous Messaging Pattern
Microservices communicate via asynchronous mechanisms such as message queues (e.g., Kafka, RabbitMQ), avoiding blocking synchronous calls.
One service publishes messages to a queue; other services subscribe and process them, achieving decoupling and asynchronous processing.
Advantages
Improves system decoupling, enhances fault tolerance and asynchronous processing capabilities.
Reduces request wait time, increasing throughput.
Disadvantages
Debugging and tracing become more complex; asynchronous logic is harder to maintain.
Requires additional messaging infrastructure, increasing system complexity.
Not suitable for real‑time or strong consistency scenarios.
Typical Use Cases
Event‑driven or asynchronous processing scenarios, such as order processing and log collection.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Mike Chen's Internet Architecture
Over ten years of BAT architecture experience, shared generously!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
