All Projects → altenwald → forseti

altenwald / forseti

Licence: LGPL-2.1 license
Process balancer and distributor for Erlang/OTP

Programming Languages

erlang
1774 projects
Makefile
30231 projects

Projects that are alternatives of or similar to forseti

optic
An Erlang/OTP library for reading and updating deeply nested immutable data.
Stars: ✭ 34 (+25.93%)
Mutual labels:  erlang-otp, erlang-library
sockerl
Sockerl is an advanced Erlang/Elixir socket framework for TCP protocols and provides fast, useful and easy-to-use API for implementing servers, clients and client connection pools.
Stars: ✭ 26 (-3.7%)
Mutual labels:  erlang-otp, erlang-library
digraph export
File conversion and export support for graphs created using the Erlang digraph module.
Stars: ✭ 33 (+22.22%)
Mutual labels:  erlang-otp, erlang-library
achlys
Erlang framework for building applications with Lasp on GRiSP
Stars: ✭ 41 (+51.85%)
Mutual labels:  erlang-otp
partial
An Erlang/OTP parse transform to emulate Scheme's cut/cute syntax.
Stars: ✭ 18 (-33.33%)
Mutual labels:  erlang-otp
hotelier
Tray App for Hotel Process Manager
Stars: ✭ 46 (+70.37%)
Mutual labels:  process-manager
Hotel
🏩 A simple process manager for developers. Start apps from your browser and access them using local domains
Stars: ✭ 9,736 (+35959.26%)
Mutual labels:  process-manager
minidb
A minimal in-memory distributed master-less document database
Stars: ✭ 29 (+7.41%)
Mutual labels:  erlang-library
Processhacker
A free, powerful, multi-purpose tool that helps you monitor system resources, debug software and detect malware.
Stars: ✭ 6,285 (+23177.78%)
Mutual labels:  process-manager
pwatch
Process watcher(pwatch)
Stars: ✭ 33 (+22.22%)
Mutual labels:  process-manager
final-pm
Finally a good node.js process manager.
Stars: ✭ 21 (-22.22%)
Mutual labels:  process-manager
nyx
Lean linux and OSX process monitoring written in C
Stars: ✭ 24 (-11.11%)
Mutual labels:  process-manager
exo
A process manager & log viewer for dev
Stars: ✭ 296 (+996.3%)
Mutual labels:  process-manager
pwa
An opinionated progressive web app boilerplate
Stars: ✭ 355 (+1214.81%)
Mutual labels:  process-manager
Process
The Process component executes commands in sub-processes.
Stars: ✭ 6,942 (+25611.11%)
Mutual labels:  process-manager
pigame
Just a game server template for Erlang/OTP.
Stars: ✭ 25 (-7.41%)
Mutual labels:  erlang-otp
firestarter
Firestarter: A process and shared socket manager
Stars: ✭ 63 (+133.33%)
Mutual labels:  process-manager
Modd
A flexible developer tool that runs processes and responds to filesystem changes
Stars: ✭ 2,030 (+7418.52%)
Mutual labels:  process-manager
Pm2
Node.js Production Process Manager with a built-in Load Balancer.
Stars: ✭ 36,126 (+133700%)
Mutual labels:  process-manager
TrivialRC
A minimalistic RC system and process manager for containers and applications
Stars: ✭ 27 (+0%)
Mutual labels:  process-manager

Forseti

Copyright (c) 2014-2017 Altenwald Solutions, S.L.

Authors: "Manuel Rubio" ([email protected]).

Build Status Codecov License: LGPL 2.1 Hex

Forseti is a balancer and distribution system for Erlang processes. The basic idea for this system is keep a basic leader/worker structure to store a process dictionary. When is needed a new process, the request should be done to the leader, the leader spawns a new process in a worker (less used worker) and the worker starts to monitor the new process. If the process dies or finishes, the worker removes the process from the dictionary (sends a request for that to the leader).

When is needed to access to an existent process, the search is done in the workers and if the search is unsuccessful, the worker send the params to the leader. If the leader doesn't find the process then it has two options:

  • Creates a new process and returns its PID (if you used forseti:get_key/1).
  • Returns undefined (if you used forseti:search/1).

IMPORTANT: forseti is designed using C (consistency) and A (availability) from the C-A-P theorem. We prefer to use forseti in a private network with a controlled connection between nodes. If you need to use different NOCs (even if you use a VPN) is not recommended to use forseti. In this situation you'll require partition-tolerant and eventual consistency.

Getting started

The implementation is very easy. You can configure it in reltool.config or in case you use relx you can add it to the .app file only. An example config (usually app.config or sys.config):

IMPORTANT if you use this way, you'll be sure forseti is loaded after all the needed resources for start to launch processes.

{forseti, [
    %% max_retries and max_time defines the maximum restart frequency for the supervisor
    {max_retries, 20},                           %% 20 by default, no mandatory
    {max_time, 10 },                             %% 10 by default, no mandatory
    {nodes, ['node1@server1', 'node2@server2']}, %% [node()] by default, no mandatory
    {call, {test_forseti, start_link, []} }      %% mandatory
]}

Otherwise you can use it in this way:

Call = {test_forseti, start_link, []},
Nodes = [node1@server1, node2@server2],
forseti:start_link(Call, Nodes),

The basic implementation for test_forseti should be a gen_server with a start_link as follows:

start_link(_Key) ->
    gen_server:start_link(?MODULE, [], []).

The function passed as a param in the form {M,F,A} should has the first param as Key.

For get a PID you can use the following function:

{Node,PID} = forseti:get_key(<<"mykey1">>),

Or passing more args to the init function:

{Node,PID} = forseti:get_key(<<"mykey1">>, [make_ref()]),

In this case, the function to be called will be start_link/2.

If you only want to search a key and in case this not exist returns undefined you can use:

case forseti:search_key(<<"mykey1">>) of
    undefined -> {error, notfound};
    {_Node,PID} -> {ok, PID}
end

Enjoy!

Multi Call Configuration

When you need to use forseti for more than one group of processes in the same virtual machine, you need to configure several calls to initiate the new processes and even a way to avoid collisions to the other configurations.

Note that if you don't use this new set of functions, you are using default keyword to locate your unique configuration actually.

The configuration could be in this way:

{forseti, [
    %% max_retries and max_time defines the maximum restart frequency for the supervisor
    {max_retries, 20},                           %% 20 by default, no mandatory
    {max_time, 10 },                             %% 10 by default, no mandatory
    {nodes, ['node1@server1', 'node2@server2']}, %% [node()] by default, no mandatory
    {call, [                                     %% mandatory
        {default, {test_forseti, start_link, []}},
        {users, {users, start_link, []}}
    ]}
]}

Using start_link you can start forseti using this way:

forseti:start_link([node1@server1, node2@server2]),
forseti:add_call(default, {test_forseti, start_link, []}),
forseti:add_call(users, {users, start_link, []}),

For the first configuration (default) you can still continue using the functions you saw in the previous sections. If you want to use explicitly default or if you want to use users, you need to do it in this way:

{ok,PID} = forseti:get(default, <<"mykey1">>),
{ok,PID} = forseti:find(default, <<"mykey1">>),

The new functions are forseti:get/2, forseti:get/3 and forseti:find/2.

Backends

Use only gen_server has several pros and cons so, I added more backends (with more pros and cons too) to let you decide what's the better implementation for your development.

mnesia

As is implemented in ejabberd, you can use mnesia as the store for the processes. This backend lets you add and remove nodes from the cluster without restart the whole cluster. The worst part is the latency. If you plan to use forseti for high load requesting location for processes, creating and removing processes, perhaps you should use another backend.

IMPORTANT: the lock_test was not working for mnesia backend because takes a lot of time to release all the processes at the same time and mnesia is not blocked in the meantime. It's dangerous to use this backend if you use it for very short live processes.

To use this backend:

forseti:start_link(mnesia, Call, Nodes)

In configuration file:

{forseti, [
    {backend, mnesia},
    {nodes, [nodes()]},
    {call, mfa()}
]}

locks

A scalable, deadlock-resolving resource locker, based on an algorithm designed by Ulf Wiger. With this backend you can add a new nodes without shutdown the cluster, but you need to start the system with one single node, after you can add more nodes.

To use this backend:

forseti:start_link(locks, Call, Nodes)

In configuration file:

{forseti, [
    {backend, locks},
    {nodes, [nodes()]},
    {call, mfa()}
]}

Modules

forseti
forseti_app
forseti_lib
forseti_locks
forseti_locks_server
forseti_mnesia
forseti_sup
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].