Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Process Registry used by Nitrogen.
Erlang Perl
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
ebin
include
src
.gitattributes
.gitignore
.travis.yml
CONTRIB.markdown
MIT-LICENSE
Makefile
README.markdown
rebar
rebar.config

README.markdown

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.

Something went wrong with that request. Please try again.