Issue
Can micro-service interact with downstream service through localhost origin, since my all service is running in same server is that is correct approach ? I found that interacting a downstream service with domain name takes much time when compared to localhost. i was curious to know whether we can do like this ?
Solution
You're right, you can communicate with other services running in the same host with localhost. It's completely fine and when thinking about network round trips, it's beneficial.
But,
- what if you want to scale the services?
- What if you want to move any of the services to a different host?
While considering at least these scenarios, binding to a specific host is not worth. And this is applicable if you are using the IP of the host.
*I found that interacting a downstream service with domain name takes much time when compared to localhost.*
.
I see what you're saying.
Microservices architecture is not a silver bullet for software development design and always come with tradeoffs
And about your deployment strategy Multiple Service Instances per Host pattern.
- How you are going to handle if your services have different resource requirements?
- say what if one of your services is utilizing all the host resource?
- What if you need to scale out one independent service?
- How you are going to ensure the availabilities of your services?
- ..
- ..
So there are so many questions you must consider before going with a pattern in microservices. It all depends on your requirements.
Answered By - Sam