In preparation for TurnKey's upcoming release based on Ubuntu Lucid 10.04 LTS, we are knocking off todo list items. One of them is code-named auto-apt-archive. As you can guess from its name, the objective is to configure the closest APT package archive mirror, automatically, without user intervention. It does this by leveraging a new GeoIP service provided by the TurnKey Hub.
By using the closest archive, it is usually much faster, will lessen the load on Ubuntu's main package archive which has been the default up until now, and in certain circumstances, cheaper (for example, bandwidth within Amazon EC2 regions is free).
BTW, TurnKey EC2 builds already include a similar optimization, which leverages ec2metadata to get its associated region and construct the URL for the region specific Ubuntu APT archives.
The new auto-apt-archive solution will replace the old Amazon EC2 adhoc solution, but will also be included in all TurnKey builds, whether it be bare-metal, virtual machines, VPS's or cloud deployment.
So how does it work
Firstly, you might recall a post I made last month, with the somewhat similar title Finding the closest data center using GeoIP and indexing. The GeoIP implementation details are similar, so I won't repeat them here.
For those interested in how auto-apt-archive works, it goes something like this:
The Hub looks up the requesting IP address using GeoIP to find the associated country code which is used in the archive URL.
Ubuntu have implemented a wildcard domain configuration for the archive mirrors, making the URL construction really simple. In the case that there is no local APT archive in your country, you will be routed to Ubuntu's main package archive. When one does become available, you'll automatically be routed there.