Reputation: 4361
I am using JHipster with 3 microservices (microservice1, microservice2, microservice3) applications, 1 JHipster registry application, and the API gateway. All applications are working as needed. I can run my 5 applications in production without problem in mode one instance by application :
microservice1 => One instance
microservice2 => One instance
microservice3 => One instance
jhipster registry=> One instance
API Gateway=> One instance
I want to have the following instance dynamically or with some automation :
microservice1 => One instance
microservice2 => One, two or more instances
microservice3 => One instance
jhipster registry=> One instance
API Gateway=> One instance
But I wonder how to instance dynamically or manually more instance of microservice2. If I want to create a new instance of service what is the best practices? : - In Jhipster configuration are set in application-prod.yml. The port is set are the creation of the application. I just avec one server. So if I cannot create a new instance on the same server! There is be a conflict IP/port because the port is configured in the application-prod.yml. How to solve it? I think it's not a good idea to create multiple configuration files with different ports in case I have to run others instances of my microservices.
Thank you for reading and for your ideas.
Upvotes: 2
Views: 3803
Reputation: 39
What we have done in our project for same thing is, we deployed same instance by creating new profile for the dynamic microservice.
Just make sure that you connect to your registry and gatway properly with new profile, jhipster will take care everthing.
MICROSERVICE A 1 (dynamic) SERVER1
MICROSERVICE A 2 (dynamic) SERVER2
MICROSERVICE B (deployedin) SERVER1
GATEWAY (deployedin) SERVER1
REGISTRY (deployedin) SERVER1
Upvotes: 0
Reputation: 1171
You can simply use the following configuration : server.port=0
Your Spring Boot application will scan for a free port on your OS and use it.
Upvotes: 4
Reputation: 121
Why don't you try some containerization (docker or rkt) to deploy microservice. This will give you flexibility of deployment, because in containerization each and every container have their own IP, so port and IP does not conflict.
Definitely after this you required some service discovery to discover your microservices to call from other microservice.
Upvotes: 0