What's the best way to run a gen_server on all nodes in an Erlang cluster?

前端 未结 2 728
名媛妹妹
名媛妹妹 2021-02-04 10:23

I\'m building a monitoring tool in Erlang. When run on a cluster, it should run a set of data collection functions on all nodes and record that data using RRD on a single \"reco

2条回答
  •  日久生厌
    2021-02-04 10:26

    I would look into riak_core. It provides a layer of infrastructure for managing distributed applications on top of the raw capabilities of erlang and otp itself. Under riak_core, no node needs to be designated as master. No node is central in an otp sense, and any node can take over other failing nodes. This is the very essence of fault tolerance. Moreover, riak_core provides for elegant handling of nodes joining and leaving the cluster without needing to resort to the master/slave policy.

    While this sort of "topological" decentralization is handy, distributed applications usually do need logically special nodes. For this reason, riak_core nodes can advertise that they are providing specific cluster services, e.g., as embodied by your use case, a results collector node.

    Another interesting feature/architecture consequence is that riak_core provides a mechanism to maintain global state visible to cluster members through a "gossip" protocol.

    Basically, riak_core includes a bunch of useful code to develop high performance, reliable, and flexible distributed systems. Your application sounds complex enough that having a robust foundation will pay dividends sooner than later.

    otoh, there's almost no documentation yet. :(

    Here's a guy who talks about an internal AOL app he wrote with riak_core:

    http://www.progski.net/blog/2011/aol_meet_riak.html

    Here's a note about a rebar template:

    http://lists.basho.com/pipermail/riak-users_lists.basho.com/2011-March/003632.html

    ...and here's a post about a fork of that rebar template:

    https://github.com/rzezeski/try-try-try/blob/7980784b2864df9208e7cd0cd30a8b7c0349f977/2011/riak-core-first-multinode/README.md

    ...talk on riak_core:

    http://www.infoq.com/presentations/Riak-Core

    ...riak_core announcement:

    http://blog.basho.com/2010/07/30/introducing-riak-core/

提交回复
热议问题