FreeBSD Ports collection is a framework for installation and management of third party software in the FreeBSD operating system. Ports are based on compiling from source code on the computer of end users. Sources are downloaded from the Internet according to lists of available locations.
This approach have certain drawbacks with regard to downloading the sources. The first server listed in a popular port will get a lot of traffic from the FreeBSD users. This is bad for server administrators, as it kills whole idea of mirrors to distribute the load. All users worldwide will download the file from the same server, which is often suboptimal for users in another part of the world then the server. Existing Ports framework have no concept of geographical preference of mirrors.
Ports tree have a feature of randomizing the order of download locations. This solves the problem of server administrator, as all listed mirrors will see an equal load. It does not solve the problem of user, as downloads will still go across the world. More, this feature is turned off by default.
GeoIP is a library to look up a real geographical location of any Internet address. It's integration into the Ports framework could solve both mentioned problems. Users will download from the nearest mirror, resulting in faster transfers, and the load will be distributed equally around the globe, no longer stressing server which happens to be listed first. With the hack I wrote, the list of possible download locations is sorted by the geographical distance between the user and the server.
This solution have it's own drawbacks, too. First, the necessary database of geographical locations is commercial and quite expensive.
This is also more an exercise than a generally useful thing, because nearest mirror is almost never the fastest one.
You will need geosort.pl script and Geo::IP Perl module (net/p5-Geo-IP). Then you will need GeoIP City Edition data file. Edit path to data file and your hostname in the script (currently these values are hardcoded). Then add this line to your /etc/make.conf:
_RANDOMIZE_SITES=" | /home/pav/geosort.pl "
Back to Pav's BSD Corner