Spring cloud registering multiple instances of the same service

I am developing a microservice using Spring Boot which provides a REST endpoint. Due to scalability, I have to run multiple instances of these services on a different port. What will be the configurations for the applications so that they can register with eureka and the requests are load balanced? I am using Spring cloud config, Eureka server and zuul.

+3


source to share


2 answers


Attaching the following entries in the client properties file will do the trick. This is for Spring cloud config dalston



eureka.instance.instanceId=${spring.application.name}:${spriโ€Œโ€‹ng.application.instaโ€Œโ€‹nce_id:${random.valuโ€Œโ€‹e}}

      

+5


source


I am assuming you wanted to register with Eureka

a server instead Config

.

To register multiple instances that can run on the same host but listening on a different port, you need to set eureka.instance.metadataMap.instanceId

to a unique value, perhaps using:



eureka.instance.metadataMap.instanceId=${spring.application.name}:${random.int}

+1


source







All Articles