spring-cloud / spring-cloud/spring-cloud-consul
Catalog Watch uses blocking queries incorrectly
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 822
- Forks
- 539
- Avg merge
- 9h 31m
- Merged PRs (30d)
- 7
Description
Hello, I'm working on Consul and have seen several users face issues around how spring-cloud-consul interfaces with Consul so I've been trying to investigate.
I've noticed that spring-cloud-consul-discovery polls the Consul catalog very frequently with short-lived blocking queries (specifically the call to /v1/catalog/services?wait=2s&index=<index> at default 1s intervals).
The intention for blocking queries is that you wait on one connection which will hold until any catalog changes are detected by the agent. It is meant to be an efficient alternative to frequent polling.
It should be enough to make one call to /v1/catalog/services?index=<index> without the default deadline of wait=2s. In fact, removing the ?wait= would drastically reduce the network traffic to Consul clients with no impact to service discovery.
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 at spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulCatalogWatch.java around line 128 and inspect how the catalog request is built. Compare it with the Consul blocking-query behavior described in the issue. Done means the index-based catalog lookup no longer applies the short default wait while service discovery behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100