Code Monkey home page Code Monkey logo

nprocreg's Introduction

nprocreg - Minimal Distributed Erlang Process Registry

Build Status

nprocreg is a global process registry built for the Nitrogen Web Framework. The goal of nprocreg is to allow Key-based lookups of a Pid, and if no Pid is found, to start a new process based on a provided Function, load-balanced newly spawned functions across the cluster.

The nprocreg gen_server, when run on a node in a Nitrogen cluster, will automatically connect to other nprocreg servers in other nodes in the cluster.

Nodes discover eachother by broadcasting out their existence to all other nodes in the cluster, retrieved by nodes(). When a node receives a message from another node, it updates a state variable, tracking the node. If enough time has passed since the last checkin, the node is removed, because we assume that the application has stopped. (Note that the node itself might still be available, we ignore this fact.)

The case that we must be careful of is when two processes look up the same Key at the same time on different nodes, potentially leading multiple Pids associated with the same key. To avoid this problem, we hash the Key to a node, and try to start the process on that node. This effectively makes process creation single threaded, drastically reducing the opportunity of creating conflicting Pids. Note that this opportunity still exists: when a new node running nprocreg is started, or an existing one is stopped, different nodes could have a different view of which nodes are available. This will happen so infrequently, and for such a short time, that we just ignore it.

nprocreg is used by the Nitrogen Web Framework.

nprocreg's People

Contributors

bjnortier avatar borisfaure avatar choptastic avatar flambard avatar jadahl avatar jaydoane avatar jdavisp3 avatar jongretar avatar leobm avatar marsik avatar mmullis avatar petrkozorezov avatar rajivr avatar robsc avatar rustyio avatar skeltoac avatar tolbrino avatar vkoivula avatar yrashk avatar zussitarze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.