Naveen Kumar
Naveen Kumar

Reputation: 973

Running multiple instance microservice using spring cloud config

I am developing a microservice, using Spring Boot, that exposes REST Endpoint.

To meet the scalability constrains, multiple instance of the [same] service will be deployed (basically scale up when needed and scale down when not needed).

I am using the Spring Cloud Config Server to supply the configuration (such as port to bound, and other configurations) to this service.

Since the service exposing REST api, How can configure the config server to supply a unique port to each instance of the microservice?

One possible solution could be, running the service in individual machine/VM or create a docker container and deploy the service. This could be my solution if there is no way to supply random port to the service from cloud config server.

Upvotes: 2

Views: 3212

Answers (2)

Vivek Baranwal
Vivek Baranwal

Reputation: 93

Have you tried using spring-cloud-bus with rabbit MQ it is basically to broadcast your configuration changes to all the instances of your application through POST bus/refresh.

Upvotes: 0

user152468
user152468

Reputation: 3242

You could start each of the three instances with a different Spring profile. E.g. SPRING_PROFILES_ACTIVE=prod1 for the first instance, SPRING_PROFILES_ACTIVE=prod2 for the second, etc.

Then you could set the port in application-prod1.properties, application-prod2.properties, etc (or in yaml files).

You could also run the app in cloudfoundry. Then cloudfoundry will create the different containers for you.

Upvotes: 2

Related Questions