Giter Club home page Giter Club logo

nano_ring's Introduction

nano_ring

NanoRing is a very very small Cluster management System in Elixir.

NanoRing needs only Elixir 0.11. It uses a simple gossip protocol to share the ring state without a master node. The 2 sets containing the ring state (all nodes and up nodes) are made convergent with a LWW-element-set state-based CRDT (http://hal.upmc.fr/docs/00/55/55/88/PDF/techreport.pdf ). The LWW-element-set containing all nodes is persistent and written on disk.

How does it work ?

The state communication works using a gossip style protocol :

  • each node has two sets : one containing all cluster nodes, and the other containing only up node.
  • every second, a node choose a random node among up-nodes, send it its 2 sets.
  • the chosen node updates its own ring merging the received ring.
  • the chosen node look if the sending node is in its up-node set, if not add it (because it knows that it has juste received a message from it, so it is not down)
  • the chosen node send an "ack" message to the sending node, so that if this node did not receive the ack after a timeout, it can remove the chosen node from its "up-set".

The whole cluster node set is persisted on-disk on each node, saved on cluster change. The up node set is initialized with all nodes.

When a node is removed (cast:del_node), remove it from the node_set but not from the up_set to allow the gossip propagates the ring. When a node see that it is not in its current cluster, delete its ring file and exit the node after 10 seconds, so that all node will remove it from their up_set.

How to test Nano Ring

First you can create 4 node launching either make multi_start if you use xterm, it will launch 4 terms with erlang nodes named dev[1,2,3,4]@127.0.0.1 running NanoRing.App.

If you cannot use xterm, you can create your own 4 terminal and launch make start_dev[1-4] on each one.

Create a cluster

By default, each node is in a ring containing only itself. To join another node, use for instance on nano_ring_dev1:

:gen_server.cast(NanoRing,{:add_node,:"[email protected]"})

If you want to remove a node, use :

:gen_server.cast(NanoRing,{:del_node,:"[email protected]"})

and wait 10 seconds.

In order to see the evolution of the cluster, you can see the whole cluster with :

:gen_server.call(NanoRing,:get_all)

To observe the available nodes of the cluster, you can use :

:gen_server.call(NanoRing,:get_up)

nano_ring's People

Contributors

awetzel avatar eraserewind avatar

Watchers

 avatar Jean Parpaillon avatar James Cloos avatar Laurent Picouleau 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.