epicpaas / appmsgsrv Goto Github PK
View Code? Open in Web Editor NEWWeb/Android/iOS 消息推送服务
License: GNU General Public License v3.0
Web/Android/iOS 消息推送服务
License: GNU General Public License v3.0
加入租户配额同步接口,用于租户配额调整。
数据库表:
quota
需要精确到客户端会话(例如:设备 1、设备 2、浏览器 tab1、浏览器 tab2)进行推送。
比如一个用户可以同时登录多个客户端,有的应用场景只需要推送给其中某个客户端。
session_id
+ @user
为 Name(key) 的方式:
session_id
是 user_id
+ _
+ device_id
(设备)/ tab_id
(浏览器)
device_id
:device_type
(iOS/Android) + -
+ real_device_id
tab_id
:browser_type
+ -
+ browser_version
+ -
+ random_num
session_id
+ @user
sessions
):
["all"]
)["xxx1", "xxx2"]
)["active"]
)["inactive"]
)api_cnt
)push_cnt
)expire
)自动分配给用户客户端 / 应用配额,使用超限后结束调用并给出受限返回值。
添加群成员:/app/client/device/addQunMember
删除群成员:/app/client/device/delQunMember
参考 会话推送
uid
+ _
+ session_id
+ @user
拼接,使用者应该只用传入 uid
作为实参在 63 搭建节点集群(每个服务进程至少两个节点)并进行测试。
场景:
用 WebSocket 协议,用 Go 开发压测工具。
demo 项目代码需要提交 /demo/xxx 。
相关数据库表:
user
org_user
(如果参数里有 orgId
则关联插入)需要对外提供 HTTP 接口:
session
表中标识出该 user_id
的某会话状态是 active
/ inactive
(应用接口 /app/client/app/setSessionState
& 设备接口 /app/client/device/setSessionState
)user_id
的会话集(应用接口 /app/client/app/getSessions
)周五下午出一个客户使用统计表,给出客户/租户使用 API 调用、实际推送统计情况。
加入发送特性。
iOS 通知时如果 APNS 返回 INVALID_TOKEN
,则删除该 apns token 记录。
在 push.go
、client.go
中实现。
在表中加入 tenant_id
、customer_id
,用于区分租户、客户。
application
加入 tenant_id
tenant
加入 customer_id
qun
加入 tenant_id
调用登录接口后需要记录下用户的设备信息,数据库表:client
baseRequest 新增参数 deviceType
baseRequest: {
"uid": "",
"deviceID": "",
"deviceType": "", // iOS / Android
"token": ""
}
具体需求与客户端开发进行讨论。
在
两个层面进行统计。
提供 用户-组织关联关系管理接口:
org_id
,返回组织下的用户 id 集user_id
,返回该用户所属的组织 id 集org_id
-user_id
,添加用户-组织关联关系org_id
-user_id
,移除用户-组织关联关系····
数据库表:
org_user
需要验证 app token。
支持客户端的
推送,同客户端部分一起进行实现设计。
syncOrg
syncTenant
(加入 customer_id
字段)相关数据库表:
customer
org
tenant
封装 HTTP 调用,降低使用难度。
接口:
方便出统计报告。
-- API 调用计数
-- 按 API
select api_name, type, sum(count) as 'sum', customer.name as 'customer_name' from api_call
inner join customer on api_call.customer_id = customer.id
where 1=1 group by type, api_name, customer_id order by api_name, type;
-- 总计
select sum(count), customer.name as 'customer_name' from api_call
inner join customer on api_call.customer_id = customer.id
where 1=1 group by customer_id;
-- 客户 TOP10 租户
select sum(count) as sum, tenant.name as 'tentant_name', customer.name as 'customer_name'
from api_call
inner join customer on api_call.customer_id = customer.id
inner join tenant on api_call.tenant_id = tenant.id
where 1=1 group by api_call.customer_id, api_call.tenant_id
order by sum desc limit 10;
----
-- 实际推送计数
-- 按类型
select push_type, type, sum(count) as 'sum', customer.name as 'customer_name' from push_cnt
inner join customer on push_cnt.customer_id = customer.id
where 1=1 group by type, push_type, customer_id order by push_type, type;
-- 总计
select sum(count) as 'sum', customer.name as 'customer_name' from push_cnt
inner join customer on push_cnt.customer_id = customer.id
where 1=1 group by customer_id;
-- 客户 TOP10 租户
select sum(count) as sum, tenant.name as 'tentant_name', customer.name as 'customer_name'
from push_cnt
inner join customer on push_cnt.customer_id = customer.id
inner join tenant on push_cnt.tenant_id = tenant.id
where 1=1 group by push_cnt.customer_id, push_cnt.tenant_id
order by sum desc limit 10;
记录内存、CPU、连接数;
压测前:
web 内存
:12m cpu
:0.1 %
message 内存
:9516 cpu
:0.0 %
comet 内存
:11m cpu
:0.0 %
mysql 内存
:2.1g cpu
: 13 %
redis 内存
:12m cpu
: 0.0 %
网络连接数:224
*/app/client/app/user/push 并发数:5000
web 内存
:1.1g cpu
:42 %
message 内存
:15m cpu
:16 %
comet 内存
:22m cpu
:19 %
mysql 内存
:2.1g cpu
:53.6 %
网络连接数:5633
10分钟发送消息:119399次
*/app/client/device/push并发数:5000
web 内存
:887m cpu
:49.6 %
message 内存
:15m cpu
:2.0 %
comet 内存
:15m cpu
:6.7 %
mysql 内存
:2.3g cpu
:64.3 %
redis 内存
:12m cpu
:7%
网络连接数:10592
10分钟发送消息:68497次
*/app/client/device/login 并发数:5000
web 内存
:968m cpu
:59.6 %
message 内存
:13m cpu
:0.0 %
comet 内存
:15m cpu
:0.0 %
mysql 内存
:2.4g cpu
:71.3 %
redis 内存
:27m cpu
:4.0%
网络连接数:7616
10分钟发送消息:111748次
20141110:网页版暂时不做,但需要完成使用 JS 客户端进行聊天,该任务作为 #15 的验证任务。
场景:
注意关注数据库和 Redis。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.