Which algorithm would be best for deciding which seedbox each torrent should go on? It must be able to fit the torrents in the minimum number of seedboxes, but also maximize the free space on each seedbox and equalize the number of torrents per seedbox. There may be other requirements for this application that I have not
screwed up thought of yet.
My current dataset is 8.9TB in 154 torrents, but both numbers will be growing. My current seedboxes can each hold 455GB, but this will probably change in the future. 8.9TB/455GB = 20 seedboxes minimum and 154/20 = around 8 torrents per box, for my current dataset & seedboxes.
My first attempt was to walk through the torrent list from largest to smallest. If the current torrent would fit on the current seedbox, put it there and remove it from the list, then move on to the next torrent. Once the complete list of torrents was walked, move on to the next seedbox, starting the list of remaining torrents over from the largest remaining.
This resulted in 20 seedboxes (the optimal solution), but I ran into two different problems:
I underestimated the overhead on each seedbox. Since I stuffed as many torrents as I could on each, box 1 ran out of space. I solved this by moving a 4GB torrent to box 19, but it would be nice if the new algorithm did a better job of spreading free space around.
I ended up with three torrents on box 0 (and eventually box 1), and 51 torrents (eventually 52) on box 19. CPU/memory utilization on a seedbox is proportional to the number of torrents, regardless of the size of each torrent. This means box 19 is doing 17 times as much work as box 0. It would be nice if the new algorithm kept the number of torrents per seedbox relatively consistent.
My subsequent attempts REALLY aren't worth discussing.
A CPAN module already implementing the algorithm would be awesome (yeah, right). If you'd like to play with live data, a list of the current torrent sizes can be found at https://freerainbowtables.com/torrents.txt