hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
278 stars 22 forks source link

NSQ: a realtime distributed messaging platform #193

Open hhstore opened 3 years ago

hhstore commented 3 years ago

related:

hhstore commented 3 years ago

NSQ:

企业用户案例:

有赞 fork 版本:

install:

ref:

竞品对比:

hhstore commented 3 years ago

nsq 架构:

nsqd:

nsqadmin:

nsqlookupd:

消息 pub/sub 模型:

生产者:

消费者:

  1. 消费者直连nsqd,这是最简单的方式,缺点是nsqd服务无法实现动态伸缩了(当然,自己去实现一个也是可以的)
  2. 消费者通过http查询nsqlookupd获取该nsqlookupd上所有nsqd的连接地址,然后再分别和这些nsqd建立连接(官方推荐的做法),但是客户端会不停的向nsqlookupd查询最新的nsqd地址目录(不喜欢用http轮询这种方式…)
hhstore commented 3 years ago

nsq 部署:

cd devops/deploy/compose/local

# 启动: 
make up.mq.nsq

部署成功验证:

admin 后台:

集群健康状态:

# 服务验证:
test.nsq:
    #  container port 4161 端口映射
    curl http://127.0.0.1:14161/ping
hhstore commented 3 years ago

集群测试:

Pub msg:

# api 测试: https://nsq.io/components/nsqd.html
test.nsq.pub1:
    curl -d "<test msg>" http://127.0.0.1:14151/pub?topic=test
    curl -d "<test channel 1 msg>" http://127.0.0.1:14151/pub?topic=test&channel=test_ch1

test.nsq.pub2:
    curl -d "<test msg>" http://127.0.0.1:14152/pub?topic=test2

image

Sub msg:

image

hhstore commented 3 years ago

与 go-micro 集成:

docs: