報告發送every 2 seconds並使用從statistics(run_queue)
收集的信息來確定具有最小負載的節點。 run_queue
返回當前節點調度器的隊列大小。
當你打電話給pool:get_node/0
時,你得到的節點上等待執行的任務數量最少。請記住,節點保持排序順序,因此對pool:get_node/0
的調用不直接查詢節點,而是依賴可能長達2秒鐘的信息。
如果您需要一個負載均衡的節點池,pool
的效果很好。
下面是從pool.erl源的一些詳細信息:
%% Supplies a computational pool of processors.
%% The chief user interface function here is get_node()
%% Which returns the name of the nodes in the pool
%% with the least load !!!!
%% This function is callable from any node including the master
%% That is part of the pool
%% nodes are scheduled on a per usgae basis and per load basis,
%% Whenever we use a node, we put at the end of the queue, and whenever
%% a node report a change in load, we insert it accordingly
太謝謝你了。 – goofansu 2013-03-23 01:16:32