im服务器开发系列,imgo是一个基于goim开发的推送服务器和IM服务器

Imgo

Imgo is a distributed and high performance push server written in golang based on goim. compared to goim,it added offline message support,add will support IM server later on.

Features

Light weight and high performance

Supports single push, multiple push and broadcasting

Supports one key to multiple subscribers (Configurable maximum subscribers count)

Supports authentication (Unauthenticated user can't subscribe)

Supports multiple protocols (WebSocket,TCP)

Supports offline message (you can push even if user is not online)

Scalable architecture (Unlimited dynamic comet,logic,router,job modules)

Asynchronous push notification based on Kafka

Architecture

Client connect to server:

625332134c6f4d4600884b99daebf603.png

A client wants to subscribe a channel on comet through tcp or websocket,comet tells logic: "Here comes a guy,shall I keep a connection with him ?".

Logic take the token from comet and showed it to store: "Is this token valid? If it is,tell me the user id".

Logic got the user id,told router this user is online and keeps a connection with that comet,and told comet:"yes, you shall".

Then comet keeps connect to that client,and matains a heartbeat with him.

Logic knowed that comet and client was keep a connection, he ask store:"Is there any offline message of that user ?","yes,three of it",store answered and gave these to logic.

Logic packed the message into an envelope and thrown to kafka.

Job found a new envelope in kafka,fetch it and read the address:"comet 1,user 123456",then he told comet 1:"tell this to user 123456".

At last,comet told this message to user 123456.

Server push message to client:

625332134c6f4d4600884b99daebf603.png

Caller(usually a bussiness system) tells logic:"I want to send hello to a person,his user id is 123456".

Logic got the user id,ask router:"Is user 123456 online ?","yes,he is keeping a connection with comet 1" router replied.

Logic packed the message into an envelope and thrown to kafka.

Job found a new envelope in kafka,fetch it and read the address:"comet 1,user 123456",then he told comet 1:"tell this to user 123456".

At last,Comet told this message to user 123456.

Protocol:

Document

Examples

Java: Java

Benchmark

625332134c6f4d4600884b99daebf603.png

Benchmark Server

CPU

Memory

OS

Instance

Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz

DDR3 32GB

Debian GNU/Linux 8

1

Benchmark Case

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

Benchmark Resource

CPU: 2000%~2300%

Memory: 14GB

GC Pause: 504ms

Network: Incoming(450MBit/s), Outgoing(4.39GBit/s)

Benchmark Result

Received: 35,900,000/s

LICENSE

imgo is is distributed under the terms of the MIT License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值