Reputation: 1521
I am using an Event Driven Microservice architecture with Rest Endpoints.
I am looking for advice on microservice roundtrip calls.
For eg, in my app I have Services "A" and "B".
Service B calls A's post method, and "A" again calls a get method on "B" to get some data to prepare the final result. I am using this approach to break cyclic dependency.
Almost all articles i have read so far talk about 'reducing' round trips and not necessarily 'eliminating' them.
What does microservice best practice say about such roundtrips ?
Upvotes: 1
Views: 305
Reputation: 164
There are three possible solutions for roundtrips depending on your architecture quality goals:
Best practice (not validated yet, but inspired from SCS): try to make 0 hops between service to answer a client request by using replicated data.
Upvotes: 0
Reputation: 2297
First of all event-driven microservices precisely avoid this kind of synchronous direct communication, by producing and consuming events from an event broker.
Anyway, it doesn't matter if you use event asynchronous communication or direct one, the lesser the communication between services the better for the performance. So in your case, the best thing you can do is to pass all the info that service B will require from service A so service B won't need to make the other call.
Using an event-driven approach, service A will produce an event with all the information required by service B and send it to a topic where service B will be listening.
Upvotes: 1