Open jameshartig opened 6 years ago
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)
@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.
This is very helpful feature. One may ask whether work is planned on this improvement in the near future?
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
andlimit: 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.