Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
geographic distance ordering for finer mirror selection #29
Issue migrated (2015-06-05) from old issue tracker http://mirrorbrain.org/issues/issue34
msg104 (view) Author: poeml Date: 2009-12-11.15:56:03
In some countries (US, Germany) there can be a wealth of mirrors. A specifically
Another scenario is that no mirror is found in the client's country, but there
Here's how a finer mirror selection could be achieved in both these cases.
The GeoLite city(!) database provides geographical coordinates. The coordinates
When clients' IP addresses are looked up via GeoIP during request processing,
Using a planar approximation of the Haversine formula, the distance to available
distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)
Thus, the available mirrors can be ordered according to their distance to the
(The simple approximation should be suitable insofar the 180° border is pretty
There is one problem, though: We use a weighted randomization to assign mirrors
This needs to be discussed.
msg111 (view) Author: poeml Date: 2009-12-21.19:12:21
I just discovered that the database scheme already contains fields for longitude
msg184 (view) Author: poeml Date: 2010-04-23.03:11:34
Geographical coordinates are meanwhile stored in the database for mirrors.
(Was implemented around r7936-r7939).
msg224 (view) Author: poeml Date: 2010-09-06.00:11:32
I haven't received any comments on this, but I'd still regard geographical
msg302 (view) Author: poeml Date: 2010-11-04.19:32:15
Something that I didn't realize earlier is that the city version of the GeoIP database
geoiplookup_city -f /var/lib/GeoIP/GeoLiteCity.dat.updated unixheads.net
It works not only for US states, but also for German Bundesländer and French
geoiplookup_city -f /var/lib/GeoIP/GeoLiteCity.dat.updated hive.aposso.de
geoiplookup_city -f /var/lib/GeoIP/GeoLiteCity.dat.updated ftp.free.fr
So another approach would be to first introduce this additional level in mirror
Another aspect is that when geographical mirror selection becomes too fine-grained,
But in the US, adding the GeoIP region (state level) would likely be beneficial.
msg303 (view) Author: poeml Date: 2010-11-04.19:43:40
Two arguments for geographical distance:
On the other hand, when we introduce "state" level in mirror selection, we would
Also, an AS match would always take precedence, which helps if a mirror is in an AS
msg304 (view) Author: poeml Date: 2010-11-05.14:10:47
Experimenting with geographical distance is promising. Here's the findings for a client in Belgium, with no
[Fri Country 'BE', Continent 'EU'
By geographical distance, a mirror in France or Netherlands would have been chosen, which sounds better than e.g.
Example of a client in Germany:
Country 'DE', Continent 'EU'
Here, the mirror in Chemnitz (right around the corner) would have been preferred.
An example with another client in Germany, this time one in the huge AS 680 which sports a lot of mirrors (only 3
Country 'DE', Continent 'EU'AS '680', Prefix '184.108.40.206/16', lat/lng 51.966702,7.633300 state id 07, state
Here, the mirror in Hagen is indeed much closer than the other two mirrors in the AS.
msg305 (view) Author: poeml Date: 2010-11-05.22:42:58
Too useful to not be implemented. Committed to trunk:
To be released with the upcoming version 2.14.0.
msg306 (view) Author: theuni Date: 2010-11-06.03:23:58
Looks very useful indeed peter, thanks!
msg309 (view) Author: poeml Date: 2010-11-11.16:23:54
The feature is in production at a few sites since a few days, and I got no
On the centos-mirror mailing list, some interesting scenarios have been discussed
Closing as "done"!
(end of migrated issue)