There is no simple answer, and some research will be necessary.
I have started down this path, but not yet had the time to fully implement ..
Start by reading:
Complex Traffic Shaping/Control
http://www.shorewall.net/traffic_shaping.htm
OpenWRT > Linux Packet Scheduling
http://wiki.openwrt.org/doc/howto/packet.scheduler/packet.scheduler.theory
OpenWRT > Bandwidth Monitoring
http://wiki.openwrt.org/doc/howto/bwmon
OpenWRT > Network Traffic Control
http://wiki.openwrt.org/doc/howto/packet.scheduler/packet.scheduler
supermind.org > Thoughts on Lucene, Solr, crawling and vertical search
http://www.supermind.org/blog/series/ubuntu-hotspot