行情分发节点信息统计(登陆人数, 合约数)
2014-05-30 16:54
309 查看
h2. 需求
* 实时统计行情分发节点的登录人数
* 以图形形式显示所有行情分发节点登陆人数总和以及
单个行情分发节点上登陆的人数
* 以图形形式现实所有行情节点带宽消耗
h2. 方案
* 行情分发节点之间一个搭建rabbit-mq节点
* 客户端连接行情分发节点时向rabbit-mq节点发送连接消息 {connetced, Login, Node, Time}
* 客户端断线时向rabbit-mq节点发送断开消息 {disconnected, Login, Node, Time}
* bigwig订阅rabbitmq,并统计各个行情分发节点的人数变化和订阅合约数量变化发送到页面(websocket)
* 页面获取websocket数据,并以Stacked column和basic area图形动态显示.
* 每天24点,页面清空,显示新一天的数据.
<pre>
{ok, Timer} = timer:send_after(EndTime, clear_charts),
{ok, #state{node_client_instrument_count = orddict:new(),
timer = Timer}}.
</pre>
* 稳定性问题
* market_dispatcher将小时用户数和合约订阅数保存在本地mnesia数据库。market_dispatcher重启时需要从mnesia load当天的统计数据
* market_dispatcher进程保存本节点的总人数和合约总订阅数目,并将总人数发送到rabbit-mq
* market_auth 重启,需要重新向rabbit-mq重新订阅统计信息
h2. 实现
* 在market_dispatch_subscribe_handler中订阅和退订的方法内调用market_subscriber_statistic模块的
on_subscribe和on_unsubscribe
<pre>
process_action(?MARKET_SUB, InstrumentIds, #state{session = Session})
process_action(?MARKET_UNSUB, [], #state{session = Session})
</pre>
* market_dispatcher中增加 market_subscriber_statistic 模块
* on_connected(Access): 向rabbitmq发送 {connected, Node, Time} (RoutingKey = <<"md_stat">>)
* on_disconnected(Access): 向rabbitmq发送 {disconnected, Node, Time}
* on_subscribe(Access): 向rabbitmq节点发送消息 {subscribe, Node, Time, Count} (Count为订阅和退订合约的数量)
* on_unsubscribe(Access): 向rabbit-mq节点发送消息 {unsubscribe, Node, Time, Count}
* market_auth中增加 market_dispatcher_amqp_subscriber 模块, http_md_stream.erl模块, http_md_statistic模块
* market_dispatcher_amqp_subscriber: 从rabbitmq接受消息,并进行统计,将数据存入orddict. (RoutingKey = <<"md_stat">>)
* node_count: {Node, Time, ClientCount, InstrumentCount}
* handle_info(clear_charts, #state{} = State)
* http_md_statistic.erl: 获取当前时间及当天之前时段的统计信息
* GET /md/statistic
* 消息格式 [[MDNode, Time, ClientCount, InstrumentCount]|...] (MDNode由原来的node()改为 market_dispatcher record 中的id)
* http_md_stream.erl: 将当前时间统计信息用websocket方式发送到浏览器
* 消息格式 [MDNode, Time, ClientCount, InstrumentCount] (MDNode由原来的node()改为 market_dispatcher record 中的id)
* websocket url: ws://localhost/md/stream
h2. 资源
* Charts 效果: http://www.highcharts.com/demo/column-stacked
* charts获取数据: http://www.highcharts.com/docs/working-with-data/preprocessing-live-data
* http://www.blueflame-software.com/blog/demo/stacked-column-chart-with-data-from-mysql-using-highcharts/
* http://jsfiddle.net/cspider/uNvnH/
h2. 待考虑问题
* rabbit-mq 重启
* market_dispatcher 重启
* market_auth 重启
* 实时统计行情分发节点的登录人数
* 以图形形式显示所有行情分发节点登陆人数总和以及
单个行情分发节点上登陆的人数
* 以图形形式现实所有行情节点带宽消耗
h2. 方案
* 行情分发节点之间一个搭建rabbit-mq节点
* 客户端连接行情分发节点时向rabbit-mq节点发送连接消息 {connetced, Login, Node, Time}
* 客户端断线时向rabbit-mq节点发送断开消息 {disconnected, Login, Node, Time}
* bigwig订阅rabbitmq,并统计各个行情分发节点的人数变化和订阅合约数量变化发送到页面(websocket)
* 页面获取websocket数据,并以Stacked column和basic area图形动态显示.
* 每天24点,页面清空,显示新一天的数据.
<pre>
{ok, Timer} = timer:send_after(EndTime, clear_charts),
{ok, #state{node_client_instrument_count = orddict:new(),
timer = Timer}}.
</pre>
* 稳定性问题
* market_dispatcher将小时用户数和合约订阅数保存在本地mnesia数据库。market_dispatcher重启时需要从mnesia load当天的统计数据
* market_dispatcher进程保存本节点的总人数和合约总订阅数目,并将总人数发送到rabbit-mq
* market_auth 重启,需要重新向rabbit-mq重新订阅统计信息
h2. 实现
* 在market_dispatch_subscribe_handler中订阅和退订的方法内调用market_subscriber_statistic模块的
on_subscribe和on_unsubscribe
<pre>
process_action(?MARKET_SUB, InstrumentIds, #state{session = Session})
process_action(?MARKET_UNSUB, [], #state{session = Session})
</pre>
* market_dispatcher中增加 market_subscriber_statistic 模块
* on_connected(Access): 向rabbitmq发送 {connected, Node, Time} (RoutingKey = <<"md_stat">>)
* on_disconnected(Access): 向rabbitmq发送 {disconnected, Node, Time}
* on_subscribe(Access): 向rabbitmq节点发送消息 {subscribe, Node, Time, Count} (Count为订阅和退订合约的数量)
* on_unsubscribe(Access): 向rabbit-mq节点发送消息 {unsubscribe, Node, Time, Count}
* market_auth中增加 market_dispatcher_amqp_subscriber 模块, http_md_stream.erl模块, http_md_statistic模块
* market_dispatcher_amqp_subscriber: 从rabbitmq接受消息,并进行统计,将数据存入orddict. (RoutingKey = <<"md_stat">>)
* node_count: {Node, Time, ClientCount, InstrumentCount}
* handle_info(clear_charts, #state{} = State)
* http_md_statistic.erl: 获取当前时间及当天之前时段的统计信息
* GET /md/statistic
* 消息格式 [[MDNode, Time, ClientCount, InstrumentCount]|...] (MDNode由原来的node()改为 market_dispatcher record 中的id)
* http_md_stream.erl: 将当前时间统计信息用websocket方式发送到浏览器
* 消息格式 [MDNode, Time, ClientCount, InstrumentCount] (MDNode由原来的node()改为 market_dispatcher record 中的id)
* websocket url: ws://localhost/md/stream
h2. 资源
* Charts 效果: http://www.highcharts.com/demo/column-stacked
* charts获取数据: http://www.highcharts.com/docs/working-with-data/preprocessing-live-data
* http://www.blueflame-software.com/blog/demo/stacked-column-chart-with-data-from-mysql-using-highcharts/
* http://jsfiddle.net/cspider/uNvnH/
h2. 待考虑问题
* rabbit-mq 重启
* market_dispatcher 重启
* market_auth 重启
相关文章推荐
- 获得指定行情分发节点的合约列表和订阅情况
- 不同行情分发节点间同步合约
- 通过使用第三方SDK来实现应用的分享,第三方登陆,数据信息统计等功能(ShareSDK)。
- python下学生管理系统:从文件中读取30位学生的信息(含邮箱),并实现简单的增、删、查找、统计(邮箱使用人数)。---附程序哦!
- 同学通信录中学生信息包括学号、姓名、联系电话、通讯地址、邮编,请设计程序统计同学录人数功能
- 求一个论坛的在线人数,假设有一个论坛,其注册ID有两亿个,每个ID从登陆到退出会向一个日志文件中记下登陆时间和退出时间,要求写一个算法统计一天中论坛的用户在线分布,取样粒度为秒。
- java统计在线人数(session存储信息的)
- 查看用户登录信息并统计登陆的次数
- JSP&Servlet 统计在线人数及信息
- 统计节点信息
- hdu 4705 dfs统计更新节点信息
- 登陆时间设置和统计人数
- 求一个论坛的在线人数,假设有一个论坛,其注册ID有两亿个,每个ID从登陆到退出会向一个日志文件中记下登陆时间和退出时间,要求写一个算法统计一天中论坛的用户在线分布,取样粒度为秒。
- 监听器实现案例----自定义session扫描器和统计在线用户人数及用户信息
- 行情分发节点列表
- 求一个论坛的在线人数,假设有一个论坛,其注册ID有两亿个,每个ID从登陆到退出会向一个日志文件中记下登陆时间和退出时间,要求写一个算法统计一天中论坛的用户在线分布,取样粒度为秒。
- C下学生管理系统:从文件中读取30位学生的信息(含邮箱),并实现简单的增、删、查找、统计(邮箱使用人数)。---附程序哦!
- 统计在线和登陆人数,管理这些用户
- 【实验】给指定的并且已登陆系统的用户发信息
- 统计在线用户(在Global.asax中使用定时器来统计在线人数和每天每月的访问量 )