Introduction
Our application is divided into logical pieces or subsystem
which has its own responsibility or data stores. When comes to development we
can develop and deploy individually, and we can realize the fastest improvement
in the development of logical pieces. But it has its Cons in aggregation the
data for reporting from different microservice or subsystems. Let us discuss
deep into this.
Overview
Here Different microservices have different data stores and
have their own responsibility it is processed via API Gateway to the client.we
may have straight forward request against the microservice from the client for a
particular module.
Problem Statement
When it comes to reporting we must produce the communication
between the microservices in order to bring the report.we should not
intercommunicate between microservice/datastore which is against the
architecture principle. where it will bring the scalability issue. let us see
that
Anti-Pattern – Intercommunication between datastores
Scenarios
1.
Materialized view
2.
Stored procedure
3.
Trigger
Description
Microservices datastore has its bounded context when we
intercommunicate between the datastores we tend to create the tightly coupled
datastore which is very hard to scale and it won't support the modern databases
like NoSql or it won't support the heterogeneous datastores. This is considered
an anti-pattern in microservices.
Cons
1.
Tight coupling between datastores
2.
Again become like monolithic, means you cant
able to deploy services individually.
3.
Hard to scale
4.
Not supported for heterogeneous datastores
Anti-Pattern – Intercommunication between Microservices
Scenarios
1.
Joining REST API calls in between microservices to produce aggregated data
Description
Each Microservices has its own context and handled by a different
small team and when it comes to intercommunication, the dependency between
teams is created and it is very hard to think about continuous delivery or
deployment. Over a period of time, it will become the chatty application and it
will produce problems in maintenance and performance.
Cons
1.
Interdependency between services will become a problem
to continuous delivery
2.
Very hard to maintain
Microservices-Pattern – Orchestrator pattern
Scenarios
1.
Composition of multiple requests into a single
request
2.
Reporting services usually collect data from
different data service
Description
When comes to reporting we need to collect data from
different service using different calls /request and compose them into a single
request. As it involves different calls this service will not be responsive and
business logic will become very clumsy or complex for a maintenance point of
view. Usually this type of pattern will be recommended for composing straight
forward request from different calls between microservices.
Cons
1.
Not responsive due to Network latency of huge
calls
2.
Not Resilient(If one of the calls fails in
composition it is very hard to figure out)
3.
Hard to maintain
4.
Hard to troubleshoot
Microservices-Pattern – Aggregator pattern
Scenarios
1.
Straightforward aggregate call without
composition/orchestration
2.
Serverless function act as orchestrator from
data receives to the topic
3.
The responsive solution where client request can
be responded without any network delay
4.
Resilient approach
5.
High data availability
Description
We can use the service broker mechanism and produce the
topics for the data we need aggregation. Here the listener service will act as
orchestrator and composition will be happened through the topics and stored in a
persistent database. Aggregator microservice will expose its own RESTFul
endpoint from where the client can make a request via proxy and it will be
responded without any network delay or failure. I will be recommending this
approach for quick response and high throughput.
Cons
1.
Complex design
2.
Careful consideration of topic and service
design is required
Conclusion
Though the aggregator pattern is the most resilient approach
to the query from different microservices. In simple words, the aggregator data
store will act as the data warehouse and aggregator microservice will act as SSRS
in our naive programming. From this article, I have provided an overview of querying
data from different microservices.
This comment has been removed by the author.
ReplyDelete