Skip to content

Latest commit

 

History

History
102 lines (77 loc) · 3.2 KB

README.md

File metadata and controls

102 lines (77 loc) · 3.2 KB

Node Vines

Motivation

Distributed software provides availability and fault-tolerance. To achieve this, a distributed program has more than one discrete process that will run on any number of devices or networks. If some of the processes in the program are partitioned or lost, the program can continue to run. All of this happens behind the scenes and the user will observe a single coherent program.

Each process in a distributed program will likely produce data and or want to act on behalf of the entire program. Each process needs to make informed decisions that are based on local data as well as data created by other processes in the program. It's not always efficient or possible to have all the processes in a network synchronize before a decision needs to be made.

Synopsis

Vines attempts to facilitate coordinated decision making through a combination of eventual consistency and quorum-based consensus. Vines may be useful for applications such as monitoring and automated provisioning.

Vines aims to be a high level solution. It implements connection machinery. If you are looking for a simple streamable gossip implementation, consider scuttlebutt.

Features

  • Quorum based consensus; a simple voting protocol that is partition tolerant.
  • Gossip based data replication; reduces network footprint in large networks.
  • Attempts automatic reconnect for peer processes before selecting a new random peer.

Examples

Data replication

A computer at 192.168.0.2 can generate some information.

  var vine = Vine()

  vine
    .listen(8000)
    .gossip('foo', 'hello, world')

A computer at 192.168.0.3 can discover that information regardless of when then peers were connected or when the data was entered.

  var vine = Vine()

  vine
    .listen(8000)
    .join(8000, '192.168.0.2')
    .on('gossip', 'foo', function(value) {
      console.log(value);
    })

Concensus

A computer at 192.168.0.2 can call an election and cast a vote.

  var electionCriteria = {
    topic: 'email',
    expire: String(new Date(now.setMinutes(now.getMinutes() + 5))),
    min: 2,
    total: 2
  }

  var vine = Vine()

  vine
    .listen(8000)
    .on('quorum', onQuorum)
    .on('expire', onExpire)
    .election(electionCriteria)
    .vote('email', true)

A computer at 192.168.0.3 can also call an election however only one of the peers will be able to execute the callback for the quorum event.

  var vine = Vine()

  vine
    .listen(8000)
    .join(8000, '192.168.0.2')
    .on('quorum', onQuorum)
    .on('expire', onExpire)
    .election(electionCriteria)
    .vote('email', true)