Reputation: 149
Say I have a user-accounts
service and a profiles
service. If the profiles
service requires data from the user-accounts
service for certain computations that means the profiles
service depends on the user-accounts
service.
Now, say additional functionality is being implemented for the user-accounts
service. This functionality requires data from the profiles
service.
This would create a cyclical dependency as each service depends on the other. Is this considered harmful?
What are some alternatives to introducing a cyclical dependency between microservices? Would it be best to add an additional service to serve as a broker?
Upvotes: 0
Views: 112
Reputation: 4190
I would try to avoid this scenario. Personally I try to avoid coupling microservices altogether and rely more on orchestration and/or event choreography.
Here are some ways that you might be able to avoid it:
user-accounts
and profiles
as a single microservice. If they're closely related, perhaps you have your service granularity slightly wrong.user-accounts
and profiles
.user-accounts
and profiles
. One service might publish events, while the other service is subscribed to these events. You can use a message broker like RabbitMQ in this type of architecture.There's no absolute right answer IMO - these are just some general guidelines - it really depends on your specific scenario...
Upvotes: 1