GithubHelp home page GithubHelp logo

isabella232 / diff-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fastly/diff-service

0.0 0.0 0.0 35 KB

An experiment in powering Edge diff functionality from Google Cloud Functions

Perl 42.11% JavaScript 56.22% Shell 1.67%

diff-service's Introduction

Diff service

If you have a website that hosts versioned copies of files such as software packages, documents or save games, which vary only slightly between versions, it makes sense to download only the difference between the version the client already has and the new one that they want. Using Fastly, we can compute the diff and generate a patch without having to add that feature to your origin server.

Fastly is a CDN, but with our Edge Cloud tools and technologies it's possible to do far more than you might think. This repo is an idea I had to demonstrate how cloud compute tools can be combined with Fastly to do very clever things at the edge.

Getting started

  1. Install prerequisites:
  2. Create a Cloud Storage bucket on Google Cloud Platform and put the name of it into the deploy.sh file
  3. Deploy the cloud function with npm run deploy and note the HTTPS URL of the deployed function
  4. Create a Fastly service with two origin servers:
    • File server hosting your static, versioned files
    • Diff service using the URL that you got from deploying the cloud function
  5. Update fastly-service.vcl with the hostname of your Cloud function
  6. Upload the VCL to your Fastly service

Testing locally

If you don't want to deploy the function to GCF to test it, you can also run a local server that makes it accessible on your machine with npm start

Rebuilding bsdiff

  1. Install Docker, to run the Google cloud platform docker instance
  2. Copy the contents of the Google Cloud platform dockerfile to an empty folder
  3. Build the container with docker build .
  4. Find the container ID with docker images
  5. Run the container with docker run -v $(pwd):/hostos -it 97bea97cfbbd /bin/bash (replace the ID with the one from the docker images output)
  6. Inside the container:
    1. Use the home directory: cd /home
    2. Download bsdiff: curl http://www.daemonology.net/bsdiff/bsdiff-4.3.tar.gz -o bsdiff.tgz
    3. Unpack: tar zxvf bsdiff.tgz
    4. Install an editor: apt-get update; apt-get install nano (or whatever editor you want to use for the next step)
    5. Apply these changes to the downloaded files:
      1. Insert a tab at the start of lines 13 and 15 of Makefile
      2. Add the line #include <sys/types.h> at the top of bspatch.c
    6. Install required library: apt-get install libbz2-dev
    7. Make! make
    8. Copy the resulting binaries to your host OS: cp bsdiff bspatch /hostos/
    9. Quit: exit

diff-service's People

Contributors

triblondon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.