Golang MQTT Broker.
以微服务+MQ构建支持高并发连接的分布式消息服务系统
Node
通过订阅MQ消息的方式,完成消息在节点间的转发n
个node, 发送m
条消息/topic/node,节点消费的需求是n
*m
条/topicGateway编程模型
根据配置选择 conf/conf.toml
conf.broker
conf.auth
# 启动Gateway,[-h]帮助查看可选参数
$ cd gateway
$ go run -tags "consul" main.go
# RPC Auth服务,[-h]帮助查看可选参数
$ cd api
$ go run -tags "consul" main.go
host
=gmqtt.k8s.hbchen.com
port
=80
gateway
broker
Developing
$ go test -run=TestClient$
# 1 client pub, sent 100000 messages, no sub
# qos 0
Total sent 100000 messages dropped 0 in 3096.074512 ms, 0.030961 ms/msg, 32298 msgs/sec
# qos 1
Total sent 100000 messages dropped 0 in 10411.318733 ms, 0.104113 ms/msg, 9604 msgs/sec
$ go test -run=TestClients$
# 1000 clients, sent 1000 messages/client, no sub
# qos 0
Total Sent 1000000 messages dropped 0 in 14628.666153 ms, 0.014629 ms/msg, 68358 msgs/sec
# qos 1
Total Sent 1000000 messages dropped 0 in 38669.812430 ms, 0.038670 ms/msg, 25859 msgs/sec
# 1000 clients, sent 1000 messages/client, 1 client sub
# qos 1
Total Sent 1000000 messages dropped 0 in 65403.199238 ms, 0.065403 ms/msg, 15289 msgs/sec
Total Received 1000000 messages in 65403.199238 ms, 0.065403 ms/msg, 15289 msgs/sec
# qos 2
Total Sent 1000000 messages dropped 0 in 68339.624216 ms, 0.068340 ms/msg, 14632 msgs/sec
Total Received 1000000 messages in 68339.624216 ms, 0.068340 ms/msg, 14632 msgs/sec
# 在.proto有import时注意相对的路径
protoc -I=$GOPATH/src:. --go_out=. api/proto/define.proto
# Start the server
$ bin/zookeeper-server-start.sh config/zookeeper.properties
$ bin/kafka-server-start.sh config/server.properties
# List topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
# Start a consumer
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic --from-beginning
# 启动报错,需修改conf/application.conf
kafka-manager.zkhosts="localhost:2181"