spring-cloud / spring-cloud/spring-cloud-netflix
Document setting eureka instance id when running multiple local apps use 'server.port=0'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5k
- Forks
- 2.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 10
Description
Trying to run multiple local instances of a service for 'testing' purposes.
I set 'server.port=0' on my local app so that when I launch an instance it picks its own port. Convenient it you want to run more than one. And I would imagine this a good fit with Eureka too since i'd hope registering the instances with eureka they would then all become known to the clients of my service.
This all seems to work... except that if start more than one instance only one of the gets effectively registered with eureka.
I think the problem is the default instance id being picked is not unique:
Described here: http://cloud.spring.io/spring-cloud-static/spring-cloud.html#_eureka_metadata_for_instances_and_clients
It is an expression that contains "${server.port}" which evaluates to 0 regardles of what port was dynamically allocated.
Logically... I think this is wrong. It should not be using "server.port" but it should use the actual port the app is running on. If it did that, then it would all just work flawlessly without me having to configure something like this to fix this problem:
eureka:
instance:
instance-id: ${spring.application.name}:${random.int}
I'm not really sure this is a 'bug' or a 'feature'. But it seems incorrect to me to use 'server.port' when the intention is probably for this to be the port the app is actually running on, which it not if "server.port=0".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Eureka metadata section linked in the issue and inspect the repository's existing documentation for eureka.instance.instance-id and server.port settings. Document how to configure or interpret the instance ID when multiple local applications use server.port=0, including the expected registration behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- cloud
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100