Thursday, December 09, 2010

yum-plugin-timemirrorbandwidth

Something I came up in during the small FAD we had in .MY last week.

Yum's fastestmirror plugin is kindof broken by design, because the plugin's definition of 'fastest' means shortest handshake time, rather than shortest download time (highest bandwidth).

If a particular country had nearby mirrors which have a really low bandwidth, fastestmirror actually made the download speed slower for users who are using it. (in my case, the nearby mirrors are extremely slow, its faster to simply force yum to grab from Taiwan mirrors, and I believe lots of local users here are also affected by this)

This plugin is a hack which complements fastestmirror by timing the metadata download time of repositories, sort them and set fastestmirror.conf to only include the top 3 mirrors with shortest metadata download time for each repository.

Source: timemirrorbandwidth.py

To install, simply copy the file into /usr/lib/yum-plugins/ and create a /etc/yum/pluginconf.d/timemirrorbandwidth.conf with this contents:

[main]
enabled=1


(I should put this in RPM i guess)

To use, simply execute:

yum time-mirrors --disableplugin=fastestmirror

the plugin will start scoring the available mirrors and add the fastest 3 mirrors for each repository into fastestmirror.conf's include_only list. I wont make this plugin to run the timing each time yum is executed, because that will mean extreme slowdown.

Feel free to improve it .. (probably i should move this into github or something).. Have fun!