LoginSignup
1
1

More than 5 years have passed since last update.

NSQ で Balancing と Bloadcast を使い分ける

Posted at

オライリー の Golang 本で NSQ を知った。
この中で NSQ でメッセージングを行っていたのだが、いざ自分で使ってみて Consumer を複数起動したときに、Producer 1 に対して Consumer 1 しか通信していなかった。
そしてきれいにバランシングしていた。

これはそもそも NSQ の正常な動作っぽい。

Guillaume's Thoughts: First look at NSQ

要は、Topic と Channels は2つのモード、 broadcastbalancing で動作する。
Producer は Topic にしかひもづかない、
Consumer は Topic -> Channel にひもづく、
というのがまず基本。
その上で、Consumer でのチャンネル名の付け方で broadcastbalancing がわかれる。

Balancing

チャンネル名を同じにする

  • Consumer1 subscribe to mytopic / mychannel
  • Consumer2 subscribe to mytopic / mychannel
  • Consumer3 subscribe to mytopic / mychannel
  • Producer1 published to mytopic

Broadcast

チャンネル名を異なるものにする

  • Consumer1 subscribe to mytopic / mychannel1
  • Consumer2 subscribe to mytopic / mychannel2
  • Consumer3 subscribe to mytopic / mychannel3
  • Producer1 published to mytopic

これで Producer が Publish するとブロードキャストするのか、バランシングするのか挙動を柔軟にかえることが出来ます。
もちろん、 broadcastbalancing をまぜることも可能性です。

参考URL

Golang / go-nsqからnsqを利用してみる - Qiita

おわり。

1
1
1

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