[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BWWNGFP6CQEGDG6PD26WZ1":3,"skill-same:01M7BWWNGFP6CQEGDG6PD26WZ1":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BWWNGFP6CQEGDG6PD26WZ1","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.","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FOpus47-OriginalSkill-79Tasks-20260920\u002Fruns\u002Fopus47-original-skill\u002Ffix-erlang-ssh-cve-opus47-original-skill-r001\u002Finputs\u002Fskills\u002Ferlang-distribution\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe","evaluation\u002Fresults\u002FOpus47-OriginalSkill-79Tasks-20260920\u002Fruns\u002Fopus47-original-skill\u002Ffix-erlang-ssh-cve-opus47-original-skill-r001\u002Finputs\u002Fskills\u002Ferlang-distribution",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill erlang-distribution",{"tool":37,"command":38},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill erlang-distribution",{"tool":40,"command":41},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill erlang-distribution","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FOpus47-OriginalSkill-79Tasks-20260920\u002Fruns\u002Fopus47-original-skill\u002Ffix-erlang-ssh-cve-opus47-original-skill-r001\u002Finputs\u002Fskills\u002Ferlang-distribution\u002FSKILL.md",true,[],[46,53,60,67,72,77],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":68,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":73,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":78,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]