I have been looking for a good solution for deploying my various web projects lately. It needed to be lightweight, easy to use, allow me to revert back quickly, and didn’t require a lot of server resources. I was leaning toward using Git but ended up using BitTorrent Sync.
You have probably heard of BitTorrent already for their ubiquitous peer-to-peer file sharing protocol and apps. BitTorrent Sync is a new beta product they have that uses a lot of the same core technology but accomplishes a different goal. It syncs folders on multiple devices (computers, tablets, phones, NAS drives, servers) without any central cloud storage service.
Using direct peer-to-peer communications has a several advantages over other cloud services like SkyDrive or Dropbox. It can sync very large files and folders without having to pay for extra cloud storage. It is more secure as transfers are encrypted by the clients and not stored on a remote server where the NSA could request them. Most importantly for my use case, it can be a lot faster.
For my deployments I wanted an easy way to push new folders or files from my development server at my house to my Windows Server 2012 web server ‘in the cloud’. There are a number of ways to do this from simple SFTP/SCP, to Git, or even IIS Web Deploy. Git was looking like a good fit, but to be honest for some small projects it seemed like overkill to have a Git repo setup.
Using BitTorrent Sync I now have a folder on my development machine that is synced with my web server. When I want to push new files I just copy them to the appropriate folder on my development machine. If I want to be able to rollback then I can just make a copy the existing folder(s) locally before I replace them. Since I’m always working with the files locally the changes are really quick, and BitTorrent Sync propagates them very quickly.
My first test was to update three WordPress blogs I maintain. To do that I needed to push 36MB of files to the server. What made this a good test is that the files are small so it was about 3000 files. Typically the low I/O performance of a single-threaded transfer protocol like SFTP or SCP makes an upload like this slow. Uploading those files using SCP took about 10 minutes but BitTorrent Sync did it in less than 2 minutes. Memory usage was also a concern of mine as I have a small VM on the Azure cloud, but most of the time it uses less than 10MB, and I haven’t seen it go higher than 40MB.
I decided to set it up with two-way synchronization, but I could have made it only sync from my PC to the server by setting it up as read-only for the server. A folder can be synced with more than two devices too, so it would be easy to allow someone else access to push files to my server. In fact, I would rather just share a folder with a novice web developer using sync than deal with the hassle and security issues of giving them SSH/SCP/Git credentials.
One quirk with BitTorrent Sync is that it doesn’t yet run as a service, it just runs in the system tray so if you log out (which is common on a server) then the app closes. To get around that until the feature is added I just setup the Windows task scheduler to launch the BTSync.exe app using my credentials when the system boots up. This sounds counter-intuitive but if you set it up this way you must uncheck the ‘Start with Windows’ box in the BitTorrent Sync settings so that it doesn’t try to launch again when you log in.
Best part of all of this is that it was just so quick and easy to setup. It took me less than 30 minutes to set it up on both machines, sync down about 1GB of websites, and update my three blogs. Check it out at BitTorrent Labs.Filed In: UncategorizedJuly 18, 2013