Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not use "blocking queries" with Consul? #374

Closed
SnailDev opened this issue May 29, 2018 · 7 comments · Fixed by #392
Closed

Why not use "blocking queries" with Consul? #374

SnailDev opened this issue May 29, 2018 · 7 comments · Fixed by #392
Labels
Consul Service discovery by Consul feature A new feature merged Issue has been merged to dev and is waiting for the next release Service Discovery Ocelot feature: Service Discovery

Comments

@SnailDev
Copy link

SnailDev commented May 29, 2018

Expected Behavior / New Feature

Many endpoints in Consul support a feature known as "blocking queries". A blocking query is used to wait for a potential change using long polling. Not all endpoints support blocking, but each endpoint uniquely documents its support for blocking queries in the documentation.

Blocking Queries could notify ocelot the latest configuration immediately (when store configuration in consul) and the latest health services immediately(when service discovery and load balancer).

@SnailDev SnailDev reopened this May 29, 2018
@SnailDev
Copy link
Author

I have read source of ocelot, with test, and I found if use service discovery and load balancer, ocelot will get health reroute server every request and it will affect performance. So I think memorycache and block queries would be useful.

@TomPallister TomPallister added feature A new feature help wanted Not actively being worked on. If you plan to contribute, please drop a note. medium effort Likely a few days of development effort labels May 29, 2018
@TomPallister
Copy link
Member

@SnailDev Thanks for your interest in the project. This sounds good, I don't know if the .net package I used to talk to Consul supports this blocking queries model you mention.

The performance impact of calling consul on every request is tiny because you should be calling consul agent as a sidecar on localhost. Yes there is a cost associated with this and polling consul for the services is a good idea and has been on my todo list for a long time!

If you would like to have a go at implementing this change I'm happy to accept a PR!

TomPallister pushed a commit that referenced this issue Jun 11, 2018
TomPallister pushed a commit that referenced this issue Jun 11, 2018
TomPallister pushed a commit that referenced this issue Jun 11, 2018
TomPallister pushed a commit that referenced this issue Jun 11, 2018
TomPallister added a commit that referenced this issue Jun 11, 2018
* WIP - implement a consul service discovery poller, lots of shared code with existing, refactor next and a todo in the docs to finish

* #374 implement polling for consul as option

* #374 updated docs to remove todo

* #374 fixed failing unit test

* #374 fixed failing unit test

* #374 fixed failing acceptance test
@TomPallister TomPallister reopened this Jun 11, 2018
@TomPallister TomPallister added the merged Issue has been merged to dev and is waiting for the next release label Jun 11, 2018
@TomPallister
Copy link
Member

I have merged a new feature that will allow users to specify if they want to poll consul

@TomPallister
Copy link
Member

Released in 7.0.5

@SnailDev
Copy link
Author

@TomPallister I have read your solution. but there are two problems:

  1. PollingConsulServiceDiscoveryProvider init on the first request and _timer poll services from consul, so the first request will be fail.
  2. _timer poll just run once. I logged in poll method and I found the log print just on first request.
private async Task Poll()
{
    _logger.LogInformation("Started polling consul");
    _services = await _consulServiceDiscoveryProvider.Get();
     _logger.LogInformation("Finished polling consul");
}

please confirm it, thank you very much.

@SnailDev
Copy link
Author

SnailDev commented Jun 20, 2018

@TomPallister by the way, may be you need to take some time to know block queries, more detail: https://www.consul.io/api/index.html , and you use consuldotnet in ocelot with consul, This API also assumes some knowledge of Consul, including things like blocking queries and consistency modes

@TomPallister
Copy link
Member

@SnailDev cool!!! It's not high on priority list at the moment but I would be happy to accept a PR if you want a challenge!

@raman-m raman-m changed the title why not use "blocking queries" with consul? Why not use "blocking queries" with Consul? Aug 15, 2024
@raman-m raman-m removed help wanted Not actively being worked on. If you plan to contribute, please drop a note. medium effort Likely a few days of development effort labels Aug 15, 2024
@raman-m raman-m added Service Discovery Ocelot feature: Service Discovery Consul Service discovery by Consul labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Consul Service discovery by Consul feature A new feature merged Issue has been merged to dev and is waiting for the next release Service Discovery Ocelot feature: Service Discovery
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants