Application deployment at scale with torrents

Reading time ~1 minute

Intro

This post will give a short overview on how to deploy your app and subsequent updates using torrents. First some basics will be covered regarding how to setup a tracker followed up by creating a customized deployment client. The use of a customized client is simply to show deeper integration, though a normal torrent client would work just as well.

Deploying apps via torrents is not a new concept by any stretch and the likes of twitter have been doing this ages ago. While the project is no longer maintained, there is a more recent tracker that can be used which gives us the same result though everything is not packaged as nicely.

Requirements

  • Torrent Tracker
  • Torrent Client
  • Configuration update code
  • Management Service

Tracker Setup

Grab the tracker config

curl -L https://raw.githubusercontent.com/chihaya/chihaya/release-v1.0/example_config.json -o config.json

start a docker instance

docker run -p 6880-6882:6880-6882 -v $PWD/config.json:/config.json:ro quay.io/jzelinskie/chihaya:v1.0.2 -v=5

First Seed

Create a torrent file using the URL ( http://localhost:6881/announce ) as your announce URL. Note in this case the localhost means we are testing on the same host. If you want to seed or download the archive from a different host, replace localhost with either the hostname or IP.

Once the torrent file is created ensure that the torrent is seeded (either locally or on a remote host).

Distribution

You can now grab the grab the deployment archive with the original torrent file created in the previous step using your torrent client of choice.

Up till this point there is not that differs from normal torrent distribution. To make this process a bit more automated we can make use of a distribution service daemon.

The management daemon runs along side your application and watches a known end point for version changes, as soon as new version is published, the service can grab the latest torrent file and start downloading + seeding the archive. Once the archive is on the host it can continue with the usual upgrade process you may have to start running the new version by either forking to a deployment script or performing the steps internally.

Conclusion

The initial setup of the tracker is a once off cost. There after all that is required to distribute your archive/application is to simply seed your distribution archive and request it on each of the distribution end points either manually or in an automated manner.

RC1140

Cross Compiling Rust Applications for windows

# Intro The basics of targetting another platform are reasonably simple. Install the relavent target platforms using rustup followed my i...… Continue reading

Race Report - Soweto Marathon

Published on November 19, 2016

Review - Theft of swords

Published on November 19, 2016