That's where bittorrent has helped me. To continue with the analogy of the ants: each server is an anthill. The update is the sandwich. Now all i need are ants at each anthill (a bittorrent client at each server) and an ant with a radio (a bittorrent tracker). As my torrent client, i chose to use uTorrent. It's a fairly small torrent client with all the features i need. Particularly, uTorrent can listen to an RSS feed and (as long as the feed is designed correctly) automatically get the torrents in the feed. In other words, if i can create an RSS feed which contains the torrent file (the descriptor file that tells torrent clients about the sandwich) then i can have all the anthills subscribe to that feed. But i get ahead of myself.
So, each anthill (server) has an army of ants (uTorrent client). Now i need a seeder, that would be someone who has the original sandwich. So, i install utorrent on my laptop (or i could use on of the servers, it doesn't really matter). I also need a tracker. Turns out the uTorrent client has a small basic tracker built in but disabled by default. So, on the client on my laptop, i go and enable it. Now all of the pieces are there to start torrenting.
For the first few torrents, i do things manually, just to make sure I've got everything setup properly.
- I open the uTorrent client on my laptop and start the 'new torrent' wizard. I point the wizard to the update file i want to share (this could also be a directory with thousands of files, no need for zipping). I also point the wizard to my laptop's IP address as the tracker. When i hit finish, uTorrent outputs a *.torrent file (i saved that to my desktop). If i look in my uTorrent client, I'll see that i'm now seeding the file and the fact that I'm seeding it has been reported to the tracker portion of the uTorrent client. Now all i need to do is get that torrent file over to the other clients. (Remember I'm doing this manually, this part will be much less complicated after i automate it.)
- I go to each one of the servers and copy the *.torrent file (2-3KB max) to each server.
- Then i open the *.torrent file using the uTorrent client on each server.
Now, to automate the process. I'm sure there is probably some perl code to automatically create a torrent from files in a certain directory, but for now, I'm still doing this manually. It only happens once every time there's an update. However, i can automate steps 2 and 3, by adding one piece of software to my laptop (obviously everything running on my laptop could actually be done on one of the servers, it's not crucial where it actually happens). The software to be added is HFS (HTTP file server). The reason i added this software is that it easily creates an RSS feed from the files in a directory. So, by adding HFS, all i have to do is save the *.torrent files in a particular directory, and they automatically get added to the RSS feed. There's some tweaking necessary for the RSS feed, so I'll detail how to do that. Once the RSS feed is setup, i can go to each of the torrent clients on the remote servers and add it to the feeds list. The client checks the RSS feed and downloads all torrents in it (there are obviously checks to make sure a torrent isn't downloaded twice). By adding the RSS functionality, steps 2 and 3 are taken care of automatically. All i have to do is save the *.torrent file in the HFS directory (saving the *.torrent file to a particular location is part of the torrent creation process, step 1).
So there you have it. I'll post instructions tomorrow on how to customize HFS to make the RSS feed compatible with uTorrent's RSS feature.
No comments:
Post a Comment