[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XD52TGPRBGQGV3KSSM389V":3,"skill-same:01M6XD52TGPRBGQGV3KSSM389V":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":13,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6XD52TGPRBGQGV3KSSM389V","erlang-distribution",null,"Use when erlang distributed systems including node connectivity, distributed processes, global name registration, distributed supervision, network partitions, and building fault-tolerant multi-node applications on the BEAM VM.","Waaaalnut\u002Fskillsbench","Waaaalnut","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F103995656?v=4","01M6XCS9K1V51EY3JMB7DGMX24","01M6XCS9Q4WPW88W62C55G1H44",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks-no-skills\u002Ffix-erlang-ssh-cve\u002Fenvironment\u002Fskills\u002Ferlang-distribution\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"erlang distribution","erlang","distribution","connectivity","when","Multi-Node","multi","processes","name","systems","beam","partitions","distributed systems","registration","use","node","applications","network","vm","distributed","2026-11-10 10:12:30",false,"---\nname: erlang-distribution\ndescription: Use when erlang distributed systems including node connectivity, distributed processes, global name registration, distributed supervision, network partitions, and building fault-tolerant multi-node applications on the BEAM VM.\n---\n\n# Erlang Distribution\n\n## Introduction\n\nErlang's built-in distribution enables building clustered, fault-tolerant systems\nacross multiple nodes. Processes on different nodes communicate transparently\nthrough the same message-passing primitives used locally. This location transparency\nmakes distributed programming natural and straightforward.\n\nThe distribution layer handles network communication, serialization, and node\nconnectivity automatically. Nodes discover each other through naming, with processes\naddressable globally via registered names or pid references. Understanding distribution\npatterns is essential for building scalable, resilient systems.\n\nThis skill covers node connectivity and clustering, distributed message passing,\nglobal name registration, distributed supervision, handling network partitions,\nRPC patterns, and building production distributed applications.\n\n## Node Connectivity\n\nNodes connect to form clusters for distributed computation and fault tolerance.\n\n```erlang\n%% Starting named nodes\n%% erl -name node1@hostname -setcookie secret\n%% erl -sname node2 -setcookie secret\n\n%% Connecting nodes\nconnect_nodes() ->\n    Node1 = 'node1@host',\n    Node2 = 'node2@host',\n    net_kernel:connect_node(Node2).\n\n%% Check connected nodes\nlist_nodes() ->\n    Nodes = [node() | nodes()],\n    io:format(\"Connected nodes: ~p~n\", [Nodes]).\n\n%% Monitor node connections\nmonitor_nodes() ->\n    net_kernel:monitor_nodes(true),\n    receive\n        {nodeup, Node} ->\n            io:format(\"Node up: ~p~n\", [Node]);\n        {nodedown, Node} ->\n            io:format(\"Node down: ~p~n\", [Node])\n    end.\n\n%% Node configuration\nstart_distributed() ->\n    {ok, _} = net_kernel:start([mynode, shortnames]),\n    erlang:set_cookie(node(), secret_cookie).\n\n%% Hidden nodes (for monitoring)\nconnect_hidden(Node) ->\n    net_kernel:connect_node(Node),\n    erlang:disconnect_node(Node),\n    net_kernel:hidden_connect_node(Node).\n\n%% Get node information\nnode_info() ->\n    #{\n        name => node(),\n        cookie => erlang:get_cookie(),\n        nodes => nodes(),\n        alive => is_alive()\n    }.\n```\n\nNode connectivity enables building distributed clusters with automatic discovery.\n\n## Distributed Message Passing\n\nSend messages to processes on remote nodes using same syntax as local messaging.\n\n```erlang\n%% Send to registered process on remote node\nsend_remote(Node, Name, Message) ->\n    {Name, Node} ! Message.\n\n%% Spawn process on remote node\nspawn_on_remote(Node, Fun) ->\n    spawn(Node, Fun).\n\nspawn_on_remote(Node, Module, Function, Args) ->\n    spawn(Node, Module, Function, Args).\n\n%% Distributed request-response\nremote_call(Node, Module, Function, Args) ->\n    Pid = spawn(Node, fun() ->\n        Result = apply(Module, Function, Args),\n        receive\n            {From, Ref} -> From ! {Ref, Result}\n        end\n    end),\n    Ref = make_ref(),\n    Pid ! {self(), Ref},\n    receive\n        {Ref, Result} -> {ok, Result}\n    after 5000 ->\n        {error, timeout}\n    end.\n\n%% Distributed work distribution\n-module(work_dispatcher).\n-export([start\u002F0, dispatch\u002F1]).\n\nstart() ->\n    register(?MODULE, spawn(fun() -> loop([]) end)).\n\ndispatch(Work) ->\n    ?MODULE ! {dispatch, Work}.\n\nloop(Workers) ->\n    receive\n        {dispatch, Work} ->\n            Node = select_node(nodes()),\n            Pid = spawn(Node, fun() -> do_work(Work) end),\n            loop([{Pid, Node} | Workers])\n    end.\n\nselect_node(Nodes) ->\n    lists:nth(rand:uniform(length(Nodes)), Nodes).\n\ndo_work(Work) ->\n    Result = process_work(Work),\n    io:format(\"Work done on ~p: ~p~n\", [node(), Result]).\n\nprocess_work(Work) -> Work * 2.\n\n%% Remote group leader for output\nremote_process_with_io(Node) ->\n    spawn(Node, fun() ->\n        group_leader(self(), self()),\n        io:format(\"Output from ~p~n\", [node()])\n    end).\n```\n\nLocation-transparent messaging enables seamless distributed communication.\n\n## Global Name Registration\n\nRegister process names globally across distributed clusters.\n\n```erlang\n%% Global registration\nregister_global(Name) ->\n    Pid = spawn(fun() -> global_loop() end),\n    global:register_name(Name, Pid),\n    Pid.\n\nglobal_loop() ->\n    receive\n        {From, Message} ->\n            From ! {reply, Message},\n            global_loop();\n        stop -> ok\n    end.\n\n%% Send to globally registered process\nsend_global(Name, Message) ->\n    case global:whereis_name(Name) of\n        undefined ->\n            {error, not_found};\n        Pid ->\n            Pid ! Message,\n            ok\n    end.\n\n%% Global name with conflict resolution\nregister_with_resolve(Name) ->\n    Pid = spawn(fun() -> server_loop() end),\n    ResolveFun = fun(Name, Pid1, Pid2) ->\n        %% Keep process on node with lower name\n        case node(Pid1) \u003C node(Pid2) of\n            true -> Pid1;\n            false -> Pid2\n        end\n    end,\n    global:register_name(Name, Pid, ResolveFun).\n\nserver_loop() ->\n    receive\n        Message ->\n            io:format(\"Received: ~p on ~p~n\", [Message, node()]),\n            server_loop()\n    end.\n\n%% Global synchronization\nsync_global() ->\n    global:sync().\n\n%% List globally registered names\nlist_global_names() ->\n    global:registered_names().\n\n%% Re-register after node reconnection\nensure_global_registration(Name, Fun) ->\n    case global:whereis_name(Name) of\n        undefined ->\n            Pid = spawn(Fun),\n            global:register_name(Name, Pid),\n            Pid;\n        Pid ->\n            Pid\n    end.\n```\n\nGlobal registration enables location-independent process discovery.\n\n## Distributed Supervision\n\nSupervise processes across multiple nodes for cluster-wide fault tolerance.\n\n```erlang\n-module(distributed_supervisor).\n-behaviour(supervisor).\n\n-export([start_link\u002F0, start_worker\u002F1]).\n-export([init\u002F1]).\n\nstart_link() ->\n    supervisor:start_link({local, ?MODULE}, ?MODULE, []).\n\nstart_worker(Node) ->\n    ChildSpec = #{\n        id => make_ref(),\n        start => {worker, start_link, [Node]},\n        restart => permanent,\n        type => worker\n    },\n    supervisor:start_child(?MODULE, ChildSpec).\n\ninit([]) ->\n    SupFlags = #{\n        strategy => one_for_one,\n        intensity => 5,\n        period => 60\n    },\n    {ok, {SupFlags, []}}.\n\n%% Worker module spawning on specific node\n-module(worker).\n-export([start_link\u002F1, loop\u002F0]).\n\nstart_link(Node) ->\n    Pid = spawn_link(Node, ?MODULE, loop, []),\n    {ok, Pid}.\n\nloop() ->\n    receive\n        stop -> ok;\n        Msg ->\n            io:format(\"Worker on ~p: ~p~n\", [node(), Msg]),\n            loop()\n    end.\n\n%% Distributed process groups\n-module(pg_example).\n-export([start\u002F0, join\u002F1, broadcast\u002F1]).\n\nstart() ->\n    pg:start_link().\n\njoin(Group) ->\n    pg:join(Group, self()).\n\nbroadcast(Group, Message) ->\n    Members = pg:get_members(Group),\n    [Pid ! Message || Pid \u003C- Members].\n```\n\nDistributed supervision maintains system health across node failures.\n\n## RPC and Remote Execution\n\nExecute function calls on remote nodes with various invocation patterns.\n\n```erlang\n%% Basic RPC\nsimple_rpc(Node, Module, Function, Args) ->\n    rpc:call(Node, Module, Function, Args).\n\n%% RPC with timeout\ntimed_rpc(Node, Module, Function, Args, Timeout) ->\n    rpc:call(Node, Module, Function, Args, Timeout).\n\n%% Async RPC\nasync_rpc(Node, Module, Function, Args) ->\n    Key = rpc:async_call(Node, Module, Function, Args),\n    %% Later retrieve result\n    rpc:yield(Key).\n\n%% Parallel RPC to multiple nodes\nparallel_rpc(Nodes, Module, Function, Args) ->\n    rpc:multicall(Nodes, Module, Function, Args).\n\n%% Parallel call with results\nparallel_rpc_results(Nodes, Module, Function, Args) ->\n    rpc:multicall(Nodes, Module, Function, Args, 5000).\n\n%% Cast (fire and forget)\ncast_rpc(Node, Module, Function, Args) ->\n    rpc:cast(Node, Module, Function, Args).\n\n%% Broadcast to all nodes\nbroadcast_rpc(Module, Function, Args) ->\n    Nodes = [node() | nodes()],\n    rpc:multicall(Nodes, Module, Function, Args).\n\n%% Parallel map over nodes\npmap_nodes(Fun, List) ->\n    Nodes = nodes(),\n    DistFun = fun(X) ->\n        Node = lists:nth((X rem length(Nodes)) + 1, Nodes),\n        rpc:call(Node, erlang, apply, [Fun, [X]])\n    end,\n    lists:map(DistFun, List).\n```\n\nRPC enables convenient remote execution with location transparency.\n\n## Network Partitions and CAP\n\nHandle network partitions and understand CAP theorem trade-offs.\n\n```erlang\n%% Detect network partition\ndetect_partition() ->\n    ExpectedNodes = [node1@host, node2@host, node3@host],\n    CurrentNodes = nodes(),\n    Missing = ExpectedNodes -- CurrentNodes,\n    case Missing of\n        [] -> ok;\n        Nodes -> {partition, Nodes}\n    end.\n\n%% Partition healing strategy\n-module(partition_handler).\n-export([monitor_cluster\u002F1]).\n\nmonitor_cluster(ExpectedNodes) ->\n    net_kernel:monitor_nodes(true),\n    monitor_loop(ExpectedNodes, nodes()).\n\nmonitor_loop(Expected, Current) ->\n    receive\n        {nodeup, Node} ->\n            NewCurrent = [Node | Current],\n            case length(NewCurrent) == length(Expected) of\n                true ->\n                    io:format(\"Cluster fully connected~n\"),\n                    heal_partition();\n                false ->\n                    ok\n            end,\n            monitor_loop(Expected, NewCurrent);\n\n        {nodedown, Node} ->\n            NewCurrent = lists:delete(Node, Current),\n            io:format(\"Partition detected: ~p~n\", [Node]),\n            monitor_loop(Expected, NewCurrent)\n    end.\n\nheal_partition() ->\n    %% Synchronize state after partition heals\n    global:sync(),\n    ok.\n\n%% Consensus with majority\n-module(consensus).\n-export([propose\u002F2, vote\u002F3]).\n\npropose(Nodes, Value) ->\n    Ref = make_ref(),\n    [Node ! {vote, self(), Ref, Value} || Node \u003C- Nodes],\n    collect_votes(Ref, length(Nodes), 0).\n\ncollect_votes(_Ref, Total, Votes) when Votes > Total div 2 ->\n    {ok, majority};\ncollect_votes(_Ref, Total, Total) ->\n    {error, no_majority};\ncollect_votes(Ref, Total, Votes) ->\n    receive\n        {vote, Ref, accept} ->\n            collect_votes(Ref, Total, Votes + 1);\n        {vote, Ref, reject} ->\n            collect_votes(Ref, Total, Votes)\n    after 5000 ->\n        {error, timeout}\n    end.\n\nvote(From, Ref, Value) ->\n    Decision = evaluate_proposal(Value),\n    From ! {vote, Ref, Decision}.\n\nevaluate_proposal(_Value) -> accept.\n```\n\nPartition handling strategies maintain system availability during network failures.\n\n## Best Practices\n\n1. **Use short names for local clusters** and long names for internet-wide distribution\n\n2. **Set same cookie** on all nodes in trusted cluster for security\n\n3. **Monitor node connections** to detect and handle network partitions\n\n4. **Use global registration sparingly** as it adds coordination overhead\n\n5. **Implement partition detection** and healing strategies for resilience\n\n6. **Design for eventual consistency** in distributed systems accepting CAP limitations\n\n7. **Use RPC for simple calls** but prefer message passing for complex protocols\n\n8. **Test with network failures** using tools like toxiproxy or chaos engineering\n\n9. **Implement proper timeouts** on distributed calls to handle slow networks\n\n10. **Use distributed supervision** to maintain fault tolerance across nodes\n\n## Common Pitfalls\n\n1. **Not setting cookies** prevents nodes from connecting causing silent failures\n\n2. **Using global registry everywhere** creates single point of failure and bottleneck\n\n3. **Not handling node disconnection** causes processes to hang indefinitely\n\n4. **Assuming network reliability** leads to incorrect behavior during partitions\n\n5. **Using long timeouts** in RPC calls causes cascading delays during failures\n\n6. **Not testing network partitions** misses critical failure modes\n\n7. **Forgetting to synchronize** global registry after partition heals\n\n8. **Using same node name** on multiple machines causes conflicts\n\n9. **Not monitoring node health** prevents detecting degraded cluster state\n\n10. **Relying on strict consistency** in distributed setting violates CAP theorem\n\n## When to Use This Skill\n\nApply distribution when building systems requiring high availability and fault tolerance.\n\nUse distributed supervision for critical services needing automatic failover.\n\nLeverage multiple nodes for horizontal scalability beyond single machine limits.\n\nImplement distributed systems when geographic distribution provides latency benefits.\n\nUse clustering for load distribution across multiple servers.\n\nApply distribution patterns for building resilient microservices architectures.\n\n## Resources\n\n- [Erlang Distribution Protocol](\u003Chttps:\u002F\u002Fwww.erlang.org\u002Fdoc\u002Fapps\u002Ferts\u002Ferl_dist_protocol.html>)\n- [Distributed Erlang](\u003Chttps:\u002F\u002Fwww.erlang.org\u002Fdoc\u002Freference_manual\u002Fdistributed.html>)\n- [Learn You Some Erlang - Distributed OTP](\u003Chttps:\u002F\u002Flearnyousomeerlang.com\u002Fdistributed-otp-applications>)\n- [Designing Distributed Systems](\u003Chttps:\u002F\u002Fwww.oreilly.com\u002Flibrary\u002Fview\u002Fdesigning-distributed-systems\u002F9781491983638\u002F>)\n- [CAP Theorem Explained](\u003Chttps:\u002F\u002Fwww.infoq.com\u002Farticles\u002Fcap-twelve-years-later-how-the-rules-have-changed\u002F>)\n","# Erlang Distribution\n\n## Introduction\n\nErlang's built-in distribution enables building clustered, fault-tolerant systems\nacross multiple nodes. Processes on different nodes communicate transparently\nthrough the same message-passing primitives used locally. This location transparency\nmakes distributed programming natural and straightforward.\n\nThe distribution layer handles network communication, serialization, and node\nconnectivity automatically. Nodes discover each other through naming, with processes\naddressable globally via registered names or pid references. Understanding distribution\npatterns is essential for building scalable, resilient systems.\n\nThis skill covers node connectivity and clustering, distributed message passing,\nglobal name registration, distributed supervision, handling network partitions,\nRPC patterns, and building production distributed applications.\n\n## Node Connectivity\n\nNodes connect to form clusters for distributed computation and fault tolerance.\n\n```erlang\n%% Starting named nodes\n%% erl -name node1@hostname -setcookie secret\n%% erl -sname node2 -setcookie secret\n\n%% Connecting nodes\nconnect_nodes() ->\n    Node1 = 'node1@host',\n    Node2 = 'node2@host',\n    net_kernel:connect_node(Node2).\n\n%% Check connected nodes\nlist_nodes() ->\n    Nodes = [node() | nodes()],\n    io:format(\"Connected nodes: ~p~n\", [Nodes]).\n\n%% Monitor node connections\nmonitor_nodes() ->\n    net_kernel:monitor_nodes(true),\n    receive\n        {nodeup, Node} ->\n            io:format(\"Node up: ~p~n\", [Node]);\n        {nodedown, Node} ->\n            io:format(\"Node down: ~p~n\", [Node])\n    end.\n\n%% Node configuration\nstart_distributed() ->\n    {ok, _} = net_kernel:start([mynode, shortnames]),\n    erlang:set_cookie(node(), secret_cookie).\n\n%% Hidden nodes (for monitoring)\nconnect_hidden(Node) ->\n    net_kernel:connect_node(Node),\n    erlang:disconnect_node(Node),\n    net_kernel:hidden_connect_node(Node).\n\n%% Get node information\nnode_info() ->\n    #{\n        name => node(),\n        cookie => erlang:get_cookie(),\n        nodes => nodes(),\n        alive => is_alive()\n    }.\n```\n\nNode connectivity enables building distributed clusters with automatic discovery.\n\n## Distributed Message Passing\n\nSend messages to processes on remote nodes using same syntax as local messaging.\n\n```erlang\n%% Send to registered process on remote node\nsend_remote(Node, Name, Message) ->\n    {Name, Node} ! Message.\n\n%% Spawn process on remote node\nspawn_on_remote(Node, Fun) ->\n    spawn(Node, Fun).\n\nspawn_on_remote(Node, Module, Function, Args) ->\n    spawn(Node, Module, Function, Args).\n\n%% Distributed request-response\nremote_call(Node, Module, Function, Args) ->\n    Pid = spawn(Node, fun() ->\n        Result = apply(Module, Function, Args),\n        receive\n            {From, Ref} -> From ! {Ref, Result}\n        end\n    end),\n    Ref = make_ref(),\n    Pid ! {self(), Ref},\n    receive\n        {Ref, Result} -> {ok, Result}\n    after 5000 ->\n        {error, timeout}\n    end.\n\n%% Distributed work distribution\n-module(work_dispatcher).\n-export([start\u002F0, dispatch\u002F1]).\n\nstart() ->\n    register(?MODULE, spawn(fun() -> loop([]) end)).\n\ndispatch(Work) ->\n    ?MODULE ! {dispatch, Work}.\n\nloop(Workers) ->\n    receive\n        {dispatch, Work} ->\n            Node = select_node(nodes()),\n            Pid = spawn(Node, fun() -> do_work(Work) end),\n            loop([{Pid, Node} | Workers])\n    end.\n\nselect_node(Nodes) ->\n    lists:nth(rand:uniform(length(Nodes)), Nodes).\n\ndo_work(Work) ->\n    Result = process_work(Work),\n    io:format(\"Work done on ~p: ~p~n\", [node(), Result]).\n\nprocess_work(Work) -> Work * 2.\n\n%% Remote group leader for output\nremote_process_with_io(Node) ->\n    spawn(Node, fun() ->\n        group_leader(self(), self()),\n        io:format(\"Output from ~p~n\", [node()])\n    end).\n```\n\nLocation-transparent messaging enables seamless distributed communication.\n\n## Global Name Registration\n\nRegister process names globally across distributed clusters.\n\n```erlang\n%% Global registration\nregister_global(Name) ->\n    Pid = spawn(fun() -> global_loop() end),\n    global:register_name(Name, Pid),\n    Pid.\n\nglobal_loop() ->\n    receive\n        {From, Message} ->\n            From ! {reply, Message},\n            global_loop();\n        stop -> ok\n    end.\n\n%% Send to globally registered process\nsend_global(Name, Message) ->\n    case global:whereis_name(Name) of\n        undefined ->\n            {error, not_found};\n        Pid ->\n            Pid ! Message,\n            ok\n    end.\n\n%% Global name with conflict resolution\nregister_with_resolve(Name) ->\n    Pid = spawn(fun() -> server_loop() end),\n    ResolveFun = fun(Name, Pid1, Pid2) ->\n        %% Keep process on node with lower name\n        case node(Pid1) \u003C node(Pid2) of\n            true -> Pid1;\n            false -> Pid2\n        end\n    end,\n    global:register_name(Name, Pid, ResolveFun).\n\nserver_loop() ->\n    receive\n        Message ->\n            io:format(\"Received: ~p on ~p~n\", [Message, node()]),\n            server_loop()\n    end.\n\n%% Global synchronization\nsync_global() ->\n    global:sync().\n\n%% List globally registered names\nlist_global_names() ->\n    global:registered_names().\n\n%% Re-register after node reconnection\nensure_global_registration(Name, Fun) ->\n    case global:whereis_name(Name) of\n        undefined ->\n            Pid = spawn(Fun),\n            global:register_name(Name, Pid),\n            Pid;\n        Pid ->\n            Pid\n    end.\n```\n\nGlobal registration enables location-independent process discovery.\n\n## Distributed Supervision\n\nSupervise processes across multiple nodes for cluster-wide fault tolerance.\n\n```erlang\n-module(distributed_supervisor).\n-behaviour(supervisor).\n\n-export([start_link\u002F0, start_worker\u002F1]).\n-export([init\u002F1]).\n\nstart_link() ->\n    supervisor:start_link({local, ?MODULE}, ?MODULE, []).\n\nstart_worker(Node) ->\n    ChildSpec = #{\n        id => make_ref(),\n        start => {worker, start_link, [Node]},\n        restart => permanent,\n        type => worker\n    },\n    supervisor:start_child(?MODULE, ChildSpec).\n\ninit([]) ->\n    SupFlags = #{\n        strategy => one_for_one,\n        intensity => 5,\n        period => 60\n    },\n    {ok, {SupFlags, []}}.\n\n%% Worker module spawning on specific node\n-module(worker).\n-export([start_link\u002F1, loop\u002F0]).\n\nstart_link(Node) ->\n    Pid = spawn_link(Node, ?MODULE, loop, []),\n    {ok, Pid}.\n\nloop() ->\n    receive\n        stop -> ok;\n        Msg ->\n            io:format(\"Worker on ~p: ~p~n\", [node(), Msg]),\n            loop()\n    end.\n\n%% Distributed process groups\n-module(pg_example).\n-export([start\u002F0, join\u002F1, broadcast\u002F1]).\n\nstart() ->\n    pg:start_link().\n\njoin(Group) ->\n    pg:join(Group, self()).\n\nbroadcast(Group, Message) ->\n    Members = pg:get_members(Group),\n    [Pid ! Message || Pid \u003C- Members].\n```\n\nDistributed supervision maintains system health across node failures.\n\n## RPC and Remote Execution\n\nExecute function calls on remote nodes with various invocation patterns.\n\n```erlang\n%% Basic RPC\nsimple_rpc(Node, Module, Function, Args) ->\n    rpc:call(Node, Module, Function, Args).\n\n%% RPC with timeout\ntimed_rpc(Node, Module, Function, Args, Timeout) ->\n    rpc:call(Node, Module, Function, Args, Timeout).\n\n%% Async RPC\nasync_rpc(Node, Module, Function, Args) ->\n    Key = rpc:async_call(Node, Module, Function, Args),\n    %% Later retrieve result\n    rpc:yield(Key).\n\n%% Parallel RPC to multiple nodes\nparallel_rpc(Nodes, Module, Function, Args) ->\n    rpc:multicall(Nodes, Module, Function, Args).\n\n%% Parallel call with results\nparallel_rpc_results(Nodes, Module, Function, Args) ->\n    rpc:multicall(Nodes, Module, Function, Args, 5000).\n\n%% Cast (fire and forget)\ncast_rpc(Node, Module, Function, Args) ->\n    rpc:cast(Node, Module, Function, Args).\n\n%% Broadcast to all nodes\nbroadcast_rpc(Module, Function, Args) ->\n    Nodes = [node() | nodes()],\n    rpc:multicall(Nodes, Module, Function, Args).\n\n%% Parallel map over nodes\npmap_nodes(Fun, List) ->\n    Nodes = nodes(),\n    DistFun = fun(X) ->\n        Node = lists:nth((X rem length(Nodes)) + 1, Nodes),\n        rpc:call(Node, erlang, apply, [Fun, [X]])\n    end,\n    lists:map(DistFun, List).\n```\n\nRPC enables convenient remote execution with location transparency.\n\n## Network Partitions and CAP\n\nHandle network partitions and understand CAP theorem trade-offs.\n\n```erlang\n%% Detect network partition\ndetect_partition() ->\n    ExpectedNodes = [node1@host, node2@host, node3@host],\n    CurrentNodes = nodes(),\n    Missing = ExpectedNodes -- CurrentNodes,\n    case Missing of\n        [] -> ok;\n        Nodes -> {partition, Nodes}\n    end.\n\n%% Partition healing strategy\n-module(partition_handler).\n-export([monitor_cluster\u002F1]).\n\nmonitor_cluster(ExpectedNodes) ->\n    net_kernel:monitor_nodes(true),\n    monitor_loop(ExpectedNodes, nodes()).\n\nmonitor_loop(Expected, Current) ->\n    receive\n        {nodeup, Node} ->\n            NewCurrent = [Node | Current],\n            case length(NewCurrent) == length(Expected) of\n                true ->\n                    io:format(\"Cluster fully connected~n\"),\n                    heal_partition();\n                false ->\n                    ok\n            end,\n            monitor_loop(Expected, NewCurrent);\n\n        {nodedown, Node} ->\n            NewCurrent = lists:delete(Node, Current),\n            io:format(\"Partition detected: ~p~n\", [Node]),\n            monitor_loop(Expected, NewCurrent)\n    end.\n\nheal_partition() ->\n    %% Synchronize state after partition heals\n    global:sync(),\n    ok.\n\n%% Consensus with majority\n-module(consensus).\n-export([propose\u002F2, vote\u002F3]).\n\npropose(Nodes, Value) ->\n    Ref = make_ref(),\n    [Node ! {vote, self(), Ref, Value} || Node \u003C- Nodes],\n    collect_votes(Ref, length(Nodes), 0).\n\ncollect_votes(_Ref, Total, Votes) when Votes > Total div 2 ->\n    {ok, majority};\ncollect_votes(_Ref, Total, Total) ->\n    {error, no_majority};\ncollect_votes(Ref, Total, Votes) ->\n    receive\n        {vote, Ref, accept} ->\n            collect_votes(Ref, Total, Votes + 1);\n        {vote, Ref, reject} ->\n            collect_votes(Ref, Total, Votes)\n    after 5000 ->\n        {error, timeout}\n    end.\n\nvote(From, Ref, Value) ->\n    Decision = evaluate_proposal(Value),\n    From ! {vote, Ref, Decision}.\n\nevaluate_proposal(_Value) -> accept.\n```\n\nPartition handling strategies maintain system availability during network failures.\n\n## Best Practices\n\n1. **Use short names for local clusters** and long names for internet-wide distribution\n\n2. **Set same cookie** on all nodes in trusted cluster for security\n\n3. **Monitor node connections** to detect and handle network partitions\n\n4. **Use global registration sparingly** as it adds coordination overhead\n\n5. **Implement partition detection** and healing strategies for resilience\n\n6. **Design for eventual consistency** in distributed systems accepting CAP limitations\n\n7. **Use RPC for simple calls** but prefer message passing for complex protocols\n\n8. **Test with network failures** using tools like toxiproxy or chaos engineering\n\n9. **Implement proper timeouts** on distributed calls to handle slow networks\n\n10. **Use distributed supervision** to maintain fault tolerance across nodes\n\n## Common Pitfalls\n\n1. **Not setting cookies** prevents nodes from connecting causing silent failures\n\n2. **Using global registry everywhere** creates single point of failure and bottleneck\n\n3. **Not handling node disconnection** causes processes to hang indefinitely\n\n4. **Assuming network reliability** leads to incorrect behavior during partitions\n\n5. **Using long timeouts** in RPC calls causes cascading delays during failures\n\n6. **Not testing network partitions** misses critical failure modes\n\n7. **Forgetting to synchronize** global registry after partition heals\n\n8. **Using same node name** on multiple machines causes conflicts\n\n9. **Not monitoring node health** prevents detecting degraded cluster state\n\n10. **Relying on strict consistency** in distributed setting violates CAP theorem\n\n## When to Use This Skill\n\nApply distribution when building systems requiring high availability and fault tolerance.\n\nUse distributed supervision for critical services needing automatic failover.\n\nLeverage multiple nodes for horizontal scalability beyond single machine limits.\n\nImplement distributed systems when geographic distribution provides latency benefits.\n\nUse clustering for load distribution across multiple servers.\n\nApply distribution patterns for building resilient microservices architectures.\n\n## Resources\n\n- [Erlang Distribution Protocol](\u003Chttps:\u002F\u002Fwww.erlang.org\u002Fdoc\u002Fapps\u002Ferts\u002Ferl_dist_protocol.html>)\n- [Distributed Erlang](\u003Chttps:\u002F\u002Fwww.erlang.org\u002Fdoc\u002Freference_manual\u002Fdistributed.html>)\n- [Learn You Some Erlang - Distributed OTP](\u003Chttps:\u002F\u002Flearnyousomeerlang.com\u002Fdistributed-otp-applications>)\n- [Designing Distributed Systems](\u003Chttps:\u002F\u002Fwww.oreilly.com\u002Flibrary\u002Fview\u002Fdesigning-distributed-systems\u002F9781491983638\u002F>)\n- [CAP Theorem Explained](\u003Chttps:\u002F\u002Fwww.infoq.com\u002Farticles\u002Fcap-twelve-years-later-how-the-rules-have-changed\u002F>)\n",{"name":5,"description":7},"main","7eeb258ada72b7f58119b0e7a2c00ea89d9beedd","tasks-no-skills\u002Ffix-erlang-ssh-cve\u002Fenvironment\u002Fskills\u002Ferlang-distribution","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench","https:\u002F\u002Fgithub.com\u002FWaaaalnut","student of Zhejiang University","2026-04-21 23:16:23",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add Waaaalnut\u002Fskillsbench --skill erlang-distribution",{"tool":56,"command":57},"bunx","bunx skills add Waaaalnut\u002Fskillsbench --skill erlang-distribution",{"tool":59,"command":60},"pnpm","pnpm dlx skills add Waaaalnut\u002Fskillsbench --skill erlang-distribution","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks-no-skills\u002Ffix-erlang-ssh-cve\u002Fenvironment\u002Fskills\u002Ferlang-distribution\u002FSKILL.md",true,[],[65,79,94,120,142,161],{"skillNo":66,"name":67,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":75,"publishedAt":38},"01M6XEWMJ6VY3ZC53MPDCPG3GH","data-reconciliation","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks\u002Fxlsx-recover-data\u002Fenvironment\u002Fskills\u002Fdata-reconciliation\u002FSKILL.md",[70],{"categoryNo":71,"categoryName":72,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[76,77,78],"data reconciliation","reconciliation","data",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":38},"01M6XEW8MNPMF1KRXV6ATGFRQF","speech-to-text","Transcribe video to timestamped text using Whisper tiny model (pre-installed).","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks\u002Fvideo-tutorial-indexer\u002Fenvironment\u002Fskills\u002Fspeech-to-text\u002FSKILL.md",[],[86,87,88,89,90,91,92,93],"speech","text","speech to text","transcribe video","whisper","model","Video","transcribe",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":105,"publishedAt":38},"01M6XEW3FQZP0T1RKQQJFXVY9T","video-processor","Process videos by removing segments and concatenating remaining parts. Use when you need to remove detected pauses\u002Fopenings from videos, create highlight reels, or batch process segment removals using ffmpeg filter_complex.","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks\u002Fvideo-silence-remover\u002Fenvironment\u002Fskills\u002Fvideo-processor\u002FSKILL.md",[100],{"categoryNo":101,"categoryName":102,"taxonomyType":103,"taxonomyTypeDesc":104},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[92,106,107,108,109,110,22,111,112,113,114,115,116,117,118,32,119],"processor","video processor","batch","create","reels","parts","segments","process","videos","you","segment","filter","ffmpeg","remove",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":127,"publishedAt":38},"01M6XEVXJ5KZ0NTY3XZKRY4AS1","silence-detector","Detect initial silence segments in audio\u002Fvideo using energy-based analysis. Use when you need to find low-energy periods at the start of recordings (title slides, setup time, pre-roll silence).","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks\u002Fvideo-silence-remover\u002Fenvironment\u002Fskills\u002Fsilence-detector\u002FSKILL.md",[126],{"categoryNo":101,"categoryName":102,"taxonomyType":103,"taxonomyTypeDesc":104},[128,129,130,131,22,115,132,133,134,135,136,112,137,138,92,139,140,141,32],"detector","silence detector","title","slides","time","energy","at","recordings","detect","find","Audio","analysis","start","setup",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":38},"01M6XEVT3NGRN1FT7JPMAPXS6M","segment-combiner","Combine multiple segment detection results into a unified list. Use when you need to merge segments from different detectors, prepare removal lists for video processing, or consolidate detection outputs.","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks\u002Fvideo-silence-remover\u002Fenvironment\u002Fskills\u002Fsegment-combiner\u002FSKILL.md",[],[116,149,92,150,151,152,153,154,22,155,156,112,115,157,158,32,159,160],"segment combiner","detection","prepare","merge","video processing","for","outputs","combine","processing","consolidate","results","list",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":170,"publishedAt":38},"01M6XEVMPVASGS2KX86QK4FMT7","report-generator","Generate compression reports for video processing. Use when you need to create structured JSON reports with duration statistics, compression ratios, and segment details after video processing.","https:\u002F\u002Fgithub.com\u002FWaaaalnut\u002Fskillsbench\u002Fblob\u002Fmain\u002Ftasks\u002Fvideo-silence-remover\u002Fenvironment\u002Fskills\u002Freport-generator\u002FSKILL.md",[167],{"categoryNo":168,"categoryName":169,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000034","行政与办公人员",[171,172,173,116,22,154,115,174,157,175,176,177,32,153,178,92,179,180,109],"generator","report generator","report","with","statistics","structured","reports","json","compression","generate"]