ankithvicky
ankithvicky

Reputation: 25

can micro-service interact with downstream service through localhost origin

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 ?

Upvotes: 0

Views: 706

Answers (3)

Soroosh Khodami
Soroosh Khodami

Reputation: 1343

Microservice is a concept, it does not force you to where you deploy your application and how they might call each other. You may deploy your microservices on different virtual machines that are hosted on the same physical server. The whole point is you need to have a reason for everything that you decide to do with your architecture. The first question is why you have split your application into different microservices? for only carrying the word of microservice on your architecture or having better control on the business logic, scalability, and maintainability of the project? These are important things you need to take care of them when you are designing an application. draw the big picture of your product, how it's going to be used. which service/component is mostly being used by the customers, does keeping it with other microservices on the same server makes performance issues or not? what if any issue happens to the server and whole applications would be unreachable.

Upvotes: 0

Sam
Sam

Reputation: 4284

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,

  1. what if you want to scale the services?
  2. 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.

  1. How you are going to handle if your services have different resource requirements?
  2. say what if one of your services is utilizing all the host resource?
  3. What if you need to scale out one independent service?
  4. How you are going to ensure the availabilities of your services?
  5. ..
  6. ..

So there are so many questions you must consider before going with a pattern in microservices. It all depends on your requirements.

Upvotes: 3

Jeyenth
Jeyenth

Reputation: 492

If your services are on the same server you should using a message broker or mechanism like grcp to talk between your services so doesn't matter if your orgin is. If you are using HTTP to communicate between your micro services then it totally not gain any advantages of micro services architecture and your architecture is flawed.

Upvotes: 0

Related Questions