レポートは2秒ごとに送信され、そこから収集された情報を使用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