In Sync Hacks, we spotlight cool uses of Sync from the creative minds of our users. Sync is our free, unlimited, and secure file-syncing application. If you have an interesting use or how-to, shoot us an email at sync[at]bittorrent.com. Can’t wait to hear what you guys cook up.
In our first edition of Sync Hacks, we have Paul Ellis (@jpaulellis). Paul uses BitTorrent Sync for web deployments. What he has to say about it? BitTorrent Sync is easy and fast. Awesome.
Thanks to Paul for giving us his how-to. Check out excerpts from it below, or read about it on his blog here.
On Choosing BitTorrent Sync
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.
Setting Up a Sync Folder For Web Deployment
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.
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.
The Experiment: Update Three Blogs
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.
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.
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.
This post has been reposted courtesy of Paul Ellis (@jpaulellis), a product owner focusing on consumer oriented products for several publicly traded companies. You can follow him on Twitter and follow his blog here.