spring-cloud / spring-cloud/spring-cloud-consul

Catalog Watch uses blocking queries incorrectly

Open
#827 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.