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

Add service limit to prepared query #4473

Open
jameshartig opened this issue Aug 1, 2018 · 3 comments
Open

Add service limit to prepared query #4473

jameshartig opened this issue Aug 1, 2018 · 3 comments
Labels
theme/prepared-query Anything related to prepared queries type/enhancement Proposed improvement or new feature

Comments

@jameshartig
Copy link
Contributor

Feature Description

(A few commenters brought up this in #1584)

Currently, when you execute a prepared query it returns all of the available services and there's no way to limit the services returned to only 1. Some SRV client libraries randomize the results which will end up clashing with Consul's ordering (whether it's random or Near: _agent). Ideally there would be a way to set a limit on a prepared query to "top 1" (or even "top x") results so that only the first service that would've been listed is returned. Additionally, the size of the DNS responses will be smaller.

Use Case(s)

In the case of Near: _agent and limit: 1 then the closest service instance will always be returned and irrespective of your particular SRV client's handling, you will always be using the closest instance.

@pierresouchay
Copy link
Contributor

pierresouchay commented Aug 1, 2018

DNS A and AAAA queries can already be limited using a_record_limit , for DNS SRV records, it makes less sense since it is used usually to discover all instances, but still, while this feature is not present, you might play easily with edns buffer size:

dig SRV redis.service.consul @localhost -p 8600 +short +bufsize=512

This of course also works with prepared queries.

Will return around 3 SRV records even if you have 500 records.

The downside is that on each request, the entries returned will be random and different (assuming you have more than 3 entries)

@pearkes pearkes added thinking More time is needed to research by the Consul Contributors type/enhancement Proposed improvement or new feature labels Aug 1, 2018
@mkeeler
Copy link
Member

mkeeler commented Aug 9, 2018

@fastest963 This seems like it would be a good addition to the prepared query interface.

We would be open to accepting a pull request for this as we don't have the bandwidth to do this at the moment.

@mkeeler mkeeler removed the thinking More time is needed to research by the Consul Contributors label Aug 9, 2018
@pavel-z1
Copy link

pavel-z1 commented May 3, 2020

This is very helpful feature.
One may ask whether work is planned on this improvement in the near future?

@jkirschner-hashicorp jkirschner-hashicorp added the theme/prepared-query Anything related to prepared queries label Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/prepared-query Anything related to prepared queries type/enhancement Proposed improvement or new feature
Projects
None yet
Development

No branches or pull requests

6 participants