LoginSignup
1
1

More than 5 years have passed since last update.

スケールアウトの方法(join)

Last updated at Posted at 2015-12-08

ROMAのスケールアウトの方法です
サービスが大きくなってきたり、一時的に負荷が上がると予想される時など、instance(サーバ)を追加することでメモリーに保持できるデータ量を増やしたり1instance(サーバ)あたりの負荷を減らすことが出来ます
help.png

条件(初期状態)

ruby version : v2.1
ROMA version : v1.2.0
server: 2台 + 1台
storage type : TokyoCabinet

ROMAの構築方法に関しては以下参照

スケールアウト

流れ

現在1instance * 2serverで運用している状態ですが、負荷が上がってきたのでもう1台ROMAサーバをクラスターへ追加することで負荷を分散し、クラスター全体のメモリー量も増加させます

構成

現在のinstance

  • 192.168.33.11_10001
  • 192.168.33.12_10001

追加するinstance

  • 192.168.33.13_20001

コマンド

既存のクラスターにinstanceを追加するには、起動コマンドであるromadにjoinオプションをつけて実行します

$ romad ${address} -p ${port} -j ${target_instance}
  • ${address} is the ip or hostname of new instance
  • ${port} is the port number of new instance
  • ${target_instance} is the one of the current instance within cluster
    • format is \${address}_${port}

手順

1. 現在の構成確認

192.168.33.11にて
$ telnet 192.168.33.11 10001
> stat node
  stats.run_receive_a_vnode {}
  routing.nodes.length 2
  routing.nodes ["192.168.33.11_10001", "192.168.33.12_10001"]
  .
  .
  .
  END

> stat run_join
  stats.run_join false

2. join

192.168.33.13にて
$ romad 192.168.33.13 -p 20001 --config ./config.rb -d -j 192.168.33.11_10001
  • ${target_instance}は192.168.33.11_10001
  • -d--configオプションも使用

3. 確認

192.168.33.13にて
$ telnet 192.168.33.13 20001
> stat node
  stats.run_receive_a_vnode {}
  routing.nodes.length 3  #=>2から3へ増えています
  routing.nodes ["192.168.33.11_10001", "192.168.33.12_10001", "192.168.33.13_20001"] #=>192.168.33.13_20001が追加されています
  .
  .
  .
  END

> stat run_join
  stats.run_join true # joinプロセスが起動中だということを表します

> stat primary|secondary
  routing.primary 7
  routing.secondary1 12
  • joinプロセスが開始すると、既存のinstanceから新しく追加したinstanceへvnodeが徐々に振り分けられていきます
  • 現在の担当vnodeはstat primary|secondaryで確認することが出来ます
  • routing.primaryrouting.secondaryの数はjoin処理が進むにつれて増えていきます
  • joinプロセスが終了するとstats.run_joinがfalseに戻ります
    • データ量やサーバスペックによってjoinプロセスにかかる時間は変わってきます

4. 終了確認

192.168.33.13にて
> stat run_join
  stats.run_join false

> stat primary|secondary
  routing.primary 170 #=>数は多少前後します
  routing.secondary1 161 #=>数は多少前後します

GUIで確認

join前

join中

image

join後

参照URL

ROMA Operation of ROMA(Adding the new ROMA process): http://roma-kvs.org/learn/operation.html#dist-jump-link-adding-title

1
1
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
1
1