0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ninda 20日目: クラスタ構成 〜Gossipとメンバーシップ〜

Last updated at Posted at 2025-12-19

今日のゴール

  • Gossipプロトコルの仕組みを理解する
  • メンバーシップ管理を学ぶ
  • ノードの動的な参加・離脱を理解する

Gossipプロトコル

噂話(Gossip)のように情報が伝播:

少数のノードに伝え、それが拡散していく。


Gossip設定

let config = GossipConfig(
  intervalMs: 1000,      # 1秒ごとにGossip
  fanout: 3,             # 各ラウンドで3ノードに送信
  suspectTimeout: 5000,  # 5秒応答なしでsuspect
  deadTimeout: 30000     # 30秒応答なしでdead
)

let node = newClusterNode("node-1", "0.0.0.0", 9000, config)

メンバーシップ管理

proc membershipExample() {.async.} =
  let node = newClusterNode("node-1", "0.0.0.0", 9000)

  # ピアを追加
  node.addPeer("node-2", "192.168.1.2", 9000)
  node.addPeer("node-3", "192.168.1.3", 9000)

  await node.start()

  # クラスタ統計
  let (tuples, peers, alive) = node.stats()
  echo "Tuples: ", tuples
  echo "Peers: ", peers
  echo "Alive: ", alive

  # ピアを削除
  node.removePeer("node-3")

  node.stop()

waitFor membershipExample()

ノードステータス遷移


まとめ

今日はクラスタ構成を学びました:

  • Gossip: 分散的な情報伝播
  • メンバーシップ: ノードの状態管理
  • 障害検出: タイムアウトベースの検出

前回: Raft合意 | 目次 | 次回: パーティショニング

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?