goim 文章系列(共5篇):
- goim 架构与定制
- 从goim定制, 浅谈 golang 的 interface 解耦合与gRPC
- goim中的 bilibili/discovery (eureka)基本概念及应用
- goim 的 data flow 数据流
- goim的业务集成(分享会小结与QA)
有个 slack 频道, 70+位朋友在交流 goim , 欢迎加入slack #goim
有几位朋友私信沟通闲聊, 想要一个同时支持 kafka / nats , 以便 merge 原有代码, 我 fork 了一个 repo 来尝试实现这个想法, 这里 https://github.com/tsingson/goim, 在这个代码尝试基础上, 与很多朋友交流/争论/碰撞…..结果,就写了一些小文章, 在上面
- 在 internal/logic/conf 与 internal/job/conf 中增加 nats 的连接配置项, 与 选择 kafka ( 默认) 或 nats 的开关配置项
- 把 internal/logic/dao 抽象为 interface , 同时支持 kafka / nats ( 仅是 nats )
- 把 internal/job 中 func (j *Job) Consume() 抽取为 interface 支持 nats
- 修改 job / logic 配置项, 从 toml 文件中读取 Nats 开关项与连接配置
除以上变更外, 所有代码尽量保持不变
goim is a im server writen by golang.
- Light weight
- High performance
- Pure Golang
- Supports single push, multiple push and broadcasting
- Supports one key to multiple subscribers (Configurable maximum subscribers count)
- Supports heartbeats (Application heartbeats, TCP, KeepAlive, HTTP long pulling)
- Supports authentication (Unauthenticated user can't subscribe)
- Supports multiple protocols (WebSocket,TCP,HTTP)
- Scalable architecture (Unlimited dynamic job and logic modules)
- Asynchronous push notification based on Kafka
make build
make run
make stop
// or
nohup target/logic -conf=target/logic.toml -region=sh -zone=sh001 -deploy.env=dev -weight=10 2>&1 > target/logic.log &
nohup target/comet -conf=target/comet.toml -region=sh -zone=sh001 -deploy.env=dev -weight=10 -addrs=127.0.0.1 2>&1 > target/logic.log &
nohup target/job -conf=target/job.toml -region=sh -zone=sh001 -deploy.env=dev 2>&1 > target/logic.log &
env:
export REGION=sh
export ZONE=sh001
export DEPLOY_ENV=dev
supervisor:
environment=REGION=sh,ZONE=sh001,DEPLOY_ENV=dev
go flag:
-region=sh -zone=sh001 deploy.env=dev
You can view the comments in target/comet.toml,logic.toml,job.toml to understand the meaning of the config.
Websocket: Websocket Client Demo
Android: Android
iOS: iOS
CPU | Memory | OS | Instance |
---|---|---|---|
Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz | DDR3 32GB | Debian GNU/Linux 8 | 1 |
- Online: 1,000,000
- Duration: 15min
- Push Speed: 40/s (broadcast room)
- Push Message: {"test":1}
- Received calc mode: 1s per times, total 30 times
- CPU: 2000%~2300%
- Memory: 14GB
- GC Pause: 504ms
- Network: Incoming(450MBit/s), Outgoing(4.39GBit/s)
- Received: 35,900,000/s
goim is is distributed under the terms of the MIT License.