构建SignalR /仪表板淘汰赛有保证的消息 [英] Building a SignalR / Knockout dashboard with guaranteed messaging

查看:265
本文介绍了构建SignalR /仪表板淘汰赛有保证的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找到使用实时通讯在我们公司更换监控仪表板。

I'm looking into replacing a monitoring dashboard at our company using real-time messaging.

在我们公司,我们有一个显示超过700的物理机(而详细的)状态的仪表板,再加上加元信息。它大约1,5年前建在ASP.NET Web窗体矿(我不喜欢),使调度员协调的一个同事在那里我们的技术人员应该去解决问题(机器位于不同地理位置)。

At our company we have a dashboard that displays the (rather detailed) status of over 700 physical machines, plus added meta-information. It was built about 1,5 years ago by a colleague of mine in ASP.NET Web Forms (which I don't like) to enable dispatchers to coordinate where our technicians should go to fix problems (the machines are located in various geographical locations).

不幸的是,应用程序使用一个30秒的完整的页面自动刷新与它背后的巨大查询。它是缓慢的,它彻底重置您的视图(正如我所说,仪表盘包含了超过700机)。就个人而言,我想改变这一点。这是非常恼人的使用。我们的调度员已经学会了忍受这一点,但我认为他们应该得到更好的。

Unfortunately, the app uses a 30-second complete page auto-refresh with a big query behind it. It's slow and it completely resets your view (as I said, the dashboard contains over 700+ machines). Personally I would like to change this. It is extremely annoying to use. Our dispatchers have learned to live with this, but I think they deserve better.

我要显示一个新的仪表板相同的内容,但实时更新和消息的日志。在我们公司,我们对一个MS栈约90%的工作,所以我计划使用ASP.NET MVC,SignalR,SQL Server和淘汰赛。

I want to display the same content on a new dashboard, but with real-time updates and "message" log. At our company we work for about 90% on a MS stack, so I plan on using ASP.NET MVC, SignalR, SQL Server and Knockout.

在这个简单的图来看看:

Take a look at this simple diagram:

 +----+ +----+ +----+ +----+ +----+ +----+ +----+            
 | PC | | PC | | PC | | PC | | PC | | PC | | PC | ... ...    
 +--+-+ +--+-+ +-+--+ +--+-+ +--+-+ +--+-+ +--+-+            
    |      |     |       |      |      |      |              
    |   +--+  +--+  +----+    <-+    <-+    <-+              
    |   |     |     |                                        
+---v---v-----v-----v+         +-----------------------+     
|                    | TCP/IP  |                       |     
| Monitoring Backend +--------->  Data Enrichment App  |     
|                    |         |                       |     
+--------------------+         +---------+-------------+     
                                         |                   
          +------------------------------+        +---------+
          |                                       |         |
          |                +----------------+     |         |
    +-----v-----+---------->    DB Proxy    +----->  S Q L  |
    |           | PUB/SUB  +----------------+     |         |
    |   Redis   |                                 |         |
    |           |          +----------------+     +---------+
    +-----------+          |     TO BE...   |                
                           +----------------+                


  • 我创建来自监视后端通过TCP / IP接收事件,并增加了额外的业务数据的事件(例如,一个小的数据富集应用时,设备的位置,一个描述性的名字旁边的主机名,一个humn可读的翻译没有包含在监控系统警报,等等)。

  • 富集的事件从应用程序到发送的Redis。我这样做,以便其他应用程序可以挂接到Redis的作为一个用户,因为我在这里输出数据优越,比监控后端发出更具可读性。

  • 目前唯一的Pub / Sub-ING到Redis是一个侦听传入的事件,并将这些对数据库(SQL Server),我已经使用历史报告的目的,但目前只包含相当简单的数据DB代理

  • 这里的想法是,以预订SignalR集线器到Redis的后端在我的ASP.NET应用火交给客户机的事件。 (这是在部分)

    The idea here is to subscribe a SignalR Hub to the Redis backend in my ASP.NET application to fire events over to the client. (That's the TO BE part)

    的想法是,当客户端导航到信息中心的网址,初始概要通过这在SQL后端的状态数据填充。之后,事件通过SignalR接收该视图更新通过改变淘汰赛属性。

    The idea is that when the client navigates to the dashboard URL, the initial overview is populated by the status data that's in the SQL backend. Afterwards, events are received through SignalR and the view is updated by changing Knockout properties.

    但是,如果一个客户端断开连接(例如,通过减少睡眠来他的笔记本电脑从会议室会议室走的时候),他错过了从SignalR中心的消息,他的仪表板视图不再是正确的!

    However, should a client get disconnected (say, by sleeping his laptop when walking from meeting room to meeting room) he misses messages from the SignalR hub, and his dashboard view is no longer correct!

    可能的解决方案是:


    1. 通过SignalR上每一个事件改变发送每个设备的完整状态:的这是因为我将不得不通过网络发送的数据量巨大的不可能。 (我猜至少达到12000条记录的JSON数据)

    1. Sending the complete status of every device through SignalR on every event change: This is impossible because of the huge amount of data I would have to send over the wire. (I'm guessing at least 12,000 records of JSON data)

    检测超时连接后强制完全刷新的:我不知道如何实现这一点使用SignalR:(

    Forcing a complete refresh after detecting a timed-out connection: I have no idea how to implement this using SignalR :(

    ...

    什么是推荐的方法来处理实时的,基于推数据并保证数据到达?或者,我会怎么对付从超时连接恢复?或者是使这种实时的疯狂的想法?

    What is the recommended approach to dealing with Real-time, push-based data and guaranteeing that data arrives? Or how would I deal with recovering from a timed-out connections? Or is the idea of making this real-time crazy?

    声明:我是一名系统工程师,而不是一个专业程序员。这是我的第一个实时的Web应用程序。其他问题有关SignalR通常不会处理大量的数据是这样的。

    Disclaimer: I'm a system engineer, not a profession programmer. This is my first real-time web app. Other questions regarding SignalR usually don't deal with large amounts of data like this.

    推荐答案

    富豪的回答是不错的,但我想在SignalR的背景下,解决方案2;您可以使用SignalR寿命事件这样的: OnConnected OnReconnected OnDisconnected 。你可以阅读更多这里的事件以及如何使用他们这里枢纽。

    spender's answer is good, but I'd like to address solution 2 in the context of SignalR; you could use the SignalR lifetime events for this: OnConnected, OnReconnected and OnDisconnected. You can read more about the events here and how to use them in a hub here.

    您会完全初始化视图当客户第一次连接(OnConnected被调用)。如果客户端暂时失去连接(默认情况下小于30s,请参阅相关这里设置, OnReconnected 被调用),你不需要做任何事情;排队的消息将被只要是在标准的排队机制足够的空间传递。

    You'd fully initialize the view when the client first connects (OnConnected gets called). If a client loses connection temporarily (by default less than 30s, see relevant settings here, OnReconnected gets called), you don't need to do anything else; the queued messages will be delivered as long as there is enough space in the standard queuing mechanism.

    如果客户端PC进入睡眠状态, OnDisconnected 被称为最终,客户将不得不建立新的连接。在这一点上,最简单的实现是简单地再次加载的所有数据。如果你想重用(过时)数据的客户端已经有,那么你需要

    If the client PC goes to sleep, OnDisconnected gets called eventually and the client will have to establish a new connection. At that point, the easiest implementation would be to simply load all data again. If you want to reuse the (outdated) data the client already has, then you'd need


    • 的方式来检索数据/消息的子集(例如,基于一个序列号或时间戳;既然你已经存储的事件流到一个数据库,它听起来像它应该是可能的整合这一点)

    • 储存只要收到一条消息,在客户端上这个号码

    • 建立连接(例如,经由<一个时,它向服务器发送href=\"http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#querystring\"相对=nofollow>查询字符串),使服务器可以在 OnConnected 阅读并知道是否要初始化一个完整的视图或仅变更

    • a way to retrieve a subset of data / messages (e.g. based on a seq number or a timestamp; Since you're already storing the event stream to a DB, it sounds like it should be possible to integrate this)
    • store this number on the client whenever it receives a message
    • send it to the server when establishing the connection (e.g. via the query string), so that the server can read it in OnConnected and knows whether to initialize a full view or only a changeset

    使用SignalR消息的实时更新应该罚款,不过我建议使用普通的MVC /控制器的WebAPI服务来初始化视图(从 OnConnected )。

    Using SignalR messaging for the real-time updates should be fine, however I'd suggest using a regular MVC / WebAPI controller to serve the full dataset necessary to initialize the view (from OnConnected).

    这是说,如果你想的保证交货,你必须ACK消息和大概也实现排队机制。 SignalR只缓存在默认情况下约1000条消息,然后开始下降他们。您可以增加价值,但它可能会更有意义制作一种适合您的需求。

    That said, if you want guaranteed delivery, you'll have to ack your messages and probably also implement a queueing mechanism. SignalR only buffers about 1000 messages by default, then it starts dropping them. You can increase that value, but it may make more sense to build one tailored to your requirements.

    这篇关于构建SignalR /仪表板淘汰赛有保证的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆