Search code examples
spring-cloud

spring cloud consul service names


I am switching all my service infrastructure from eureka to consul.

In the eureka case I have multiple services with the same name and Eureka handles this via the Application and instance to differentiate.

In the consul case, if I have this naming scheme, does spring cloud generate unique ids under eh covers?

I read where consul will use the id and name synonymously unless you register them under unique ids.

So you can have service 1 as (name=myservice, id=xxx) and service 2 as (name=myservice, id=yyy).

So in that way consul preserves uniqueness. What does spring cloud do under the covers?


Ok, so it appears that the question is not clear.

I know that I can specify uniqueness when I define them but I don't

I have a large microservices-based system in production. We have multiples of each microservices for both redundancy and scaling and we do not specifically set uniqueness on the services.

We don't because Eureka does this for us. Say I have a CustomerAccountService with 5 instances then I when I request customer account service I can see 5 instances. Looking at the Eureka data model, we see one Application and 5 instances of it.

So I am planning on moving to consul and want t preserve a similar mode of operation. Many instances of the same time of service.

What I really want to know is how the spring consul registration works under the covers or do I have to do something special for this.

I do know that COnsul defines a name and an id and that they can be the same or they can be different.

So can I have the name for 5 instances the same and have the id variate? If so, how does that happen in the spring cloud consul version of this.


Solution

  • Any application registered with the same spring.application.name in Consul using Spring Cloud will be grouped together just like Eureka.