im服务器开发系列,imgo是一个基于goim开发的推送服务器和IM服务器_投妍帮的博客-程序员宅基地

技术标签: 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.

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42382748/article/details/119550480

智能推荐

Mask R-CNN 理解_maskrvnn-程序员宅基地

MASK RCNN 算法介绍:Mask-RCNN 是何凯明大神继Faster-RCNN后的又一力作,集成了物体检测和实例分割两大功能,并且在性能上上也超过了Faster-RCNN。整体框架:图1. Mask-RCNN 整体架构图2.Faster-RCNN 整体架构对比两张图可以很明显的看出,在Faster-RCNN的基础之上,Mask-RCNN加入了Mask branch(FCN)用于生成物体的掩模(object mask), 同时把RoI pooling 修改成为了RoI Align 用于处_maskrvnn

《Adobe Photoshop CS6中文版经典教程(彩色版)》—第1课1.2节使用工具-程序员宅基地

本节书摘来自异步社区《Adobe Photoshop CS6中文版经典教程(彩色版)》一书中的第1课1.2节使用工具,作者【美】Adobe公司,更多章节内容可以访问云栖社区“异步社区”公众号查看。1.2 使用工具Adobe Photoshop CS6中文版经典教程(彩色版)Photoshop为制作用于打印、在线浏览和移动观看的高级图形提供了一整套工具。...

MySQL中级优化教程(六)——表的范式化和反范式化-程序员宅基地

您可以到这里下载本篇博文所使用的数据库以及优化工具mysqldumpslow和pt-query-digest: https://blog.csdn.net/IT_TIfarmer/article/details/92224646 关于explain语句的结果参数详解也可以参考如上博文。 前言:范式化是指数据库设计的规范,目前说范式化,一般是指第三设计范式,也就..._范式化

JavaScript高级篇_小杨洋的博客-程序员宅基地

JavaScript高级篇一 arguments: 1.在JavaScript中,每一个函数都包含一个arguments属性 2.arguments属性是一个数组 3.在函数调用时,将实参传入函数的arguments中,再由arguments将数据传递给形参 4.arguments属性存在,可以将JavaScript中的函数在调用时传递实参与形参进行隔离 ...

ACM 几何基础(1)-程序员宅基地

点 point定义 :struct point{double x,y;};线 line定义 :Struct line{Point s,e;};精度差 Const double eps=1e-8;Int sgn(double x){If(fabs(x)If(xElse return 1;}直线1)一般形式:ax+

编译ORBSLAM2问题解决_recipe for target '/home/why/vdo_slam-master/lib/l-程序员宅基地

在安装的时候记得source Examples/ROS/ORB_SLAM2/build/devel/setup.bash在编译ubuntu16.04ros包的时候出现以下问题`/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol ‘_ZN5boost6system15system_c..._recipe for target '/home/why/vdo_slam-master/lib/libobjslam.so' failed

随便推点

html5第九课时,3.外部js-程序员宅基地

html>html>head lang="en"> meta charset="UTF-8"> title>js使用方式3.外部jstitle> script src="../../js/test.js" language="JavaScript"> script>head>body>input type="button" value="第三种js方式"_外部js

如何理解Java是跨平台的语言_java是跨平台的编程语言吗-程序员宅基地

今天看了个视频,浅谈如何理解Java是跨平台的语言。_java是跨平台的编程语言吗

h5-attribute和property_h5attribute-程序员宅基地

1.什么是attribute,什么是property属性?attribute:html自定义属性 html预定义属性property:js原生对象的直接属性每一个预定义的attribute都会有一个property与之对应2.什么是布尔值属性,什么是非布尔值属性?同步关系布尔值属性:你的property是布尔值类型 checked就是布尔值属性改变property不会同步attribute在没有动过property时,attribute会同步property一旦动过就不会同步非_h5attribute

HDU2159FATE(二维费用背包)_hdu 二维费用背包-程序员宅基地

解题思路:第二题二维费用背包了,有些许的理解,状态设计:dp[z][j]表示杀z个怪花费不超过j的情况下得到的最大经验值状态转移方程:dp[z][j]=max(dp[z][j],dp[z-1][j-cost[i]]+value[i])相当于多一维限定杀敌数的花费,而你要多杀一个人一定是从你杀的z-1个人的状态推导过来的。j的那个循环控制到底是01背包还是完全背包AC代码如下:#include&lt..._hdu 二维费用背包

IntelliJ IDEA 学习笔记 - Debug 介绍-程序员宅基地

本文简单介绍IntelliJ IDEA中Debug的使用技巧

机器学习算法复习---聚类算法之KMeans_kmeans聚类算法机器学习代码 kmeans(dataset, k, distmeas=diste-程序员宅基地

了解基础的机器学习知识即了解基础的机器学习的一些名词但没有实现过机器学习算法的人观看且对python不了解的也可以看,每一处具有注释。本文使用的python3编译环境,与python2编译环境有一些差别,不过不影响大体。本文的理论部分以西瓜书和统计学习方法为参考,代码实现以机器学习实战为参考。 好!开始上代码!主要介绍聚类算法中的KMeans算法,其他的陆续更..._kmeans聚类算法机器学习代码 kmeans(dataset, k, distmeas=disteclud, createcent