m-lab / ndt-server

docker native ndt5 and ndt7 server with prometheus integration
https://www.measurementlab.net/
Apache License 2.0
99 stars 40 forks source link

Locate v2 API country filter fails with many geographically dispersed servers in country #398

Closed mrdvt92 closed 4 months ago

mrdvt92 commented 7 months ago

The query http://locate.measurementlab.net/v2/nearest/ndt/ndt7?country=US appears to return results simply based on the "country" center point (e.g. Kansas for the US) but in the US there are many geographically dispersed servers and the servers returned by the US country filter are not optimal test servers.

$ curl -is 'http://locate.measurementlab.net/v2/nearest/ndt/ndt7?country=US' | egrep -B 1 'country|^X-'
Cache-Control: no-store
X-Locate-Clientlatlon: 37.09024,-95.712891
X-Locate-Clientlatlon-Method: user-country
--
        "city": "Omaha",
        "country": "US"
--
        "city": "Dallas",
        "country": "US"
--
        "city": "Dallas",
        "country": "US"
--
        "city": "Dallas",
        "country": "US"

But, without the US country filter, the results are a more logical server subset.

$ curl -is 'http://locate.measurementlab.net/v2/nearest/ndt/ndt7' | egrep -B 1 'country|^X-'
Cache-Control: no-store
X-Locate-Clientlatlon: 38.840391,-77.428877
X-Locate-Clientlatlon-Method: appengine-latlong
--
        "city": "Washington",
        "country": "US"
--
        "city": "Washington",
        "country": "US"
--
        "city": "Washington",
        "country": "US"
--
        "city": "Washington",
        "country": "US"

I recommend that the logic behind the country filter first perform a geographic select then a text string country filter.

The filter logic should also support a country filter list.

$ curl -is 'http://locate.measurementlab.net/v2/nearest/ndt/ndt7?country=US&country=PR&country=VI&country=GU&country=MP&country=AS' | egrep -B 1 'country|^X-'
Cache-Control: no-store
X-Locate-Clientlatlon: 37.09024,-95.712891
X-Locate-Clientlatlon-Method: user-country
--
        "city": "Omaha",
        "country": "US"
--
        "city": "Dallas",
        "country": "US"
--
        "city": "Dallas",
        "country": "US"
--
        "city": "Dallas",
        "country": "US"
nkinkade commented 4 months ago

@mrdvt92: I apologize that this issue went unanswered for so long. You may or may not be aware of this, but I believe your suggestion was already implemented in the Locate Service with this PR:

https://github.com/m-lab/locate/pull/177

Try adding the query string ?country=US&strict=true. I'm going to close this issue because a) I believe it is resolved b) it is not related to ndt-server. If something is still wrong, please open a new issue on the Locate repository.