【发布时间】:2016-06-06 16:25:57
【问题描述】:
所以快速更新一下我为什么创建这个问题。
我们目前将设备的遥测数据存储在 Azure SQL Server 的现场。这很好用(在 EF、LINQ 和关系数据库方面有大量经验)但我知道这很可能不是最好的解决方案,尤其是对于存储“大”数据(数据现在仍然很小,但会在一年内增长) )。
我选择了 DocumentDB 作为我们可能的解决方案来存储我们的事件历史。其余的将留在 SQL 中 - 用户、配置文件、设备信息、SIM、车辆等,因为我不想完全停止开发,因为我们将 100% 迁移到 docdb,而只是做短期内最好的事情 - 成本 + 性能。
通过这个视频,我终于想出了一个关于如何存储遥测数据的可能解决方案 - https://www.youtube.com/watch?v=-o_VGpJP-Q0 他们建议每个时间段一个文档(示例使用每小时 1 个)。这仍然是推荐的方法吗?
[Index]
public DateTime TimestampUtc { get; set; }
public DateTime ReceivedTimestampUtc { get; set; }
[Index]
public EventType EventType { get; set; }
public Guid ConnectionId { get; set; }
public string RawEventMessage { get; set; }
[Index]
public Sender Sender { get; set; }
[Index]
public Channel Channel { get; set; }
public DbGeography Location { get; set; }
public double? Speed { get; set; }
public double? Altitude { get; set; }
public Int16? Heading { get; set; }
public Byte? HDOP { get; set; }
public Byte? GPSFixStatus { get; set; }
public Byte? GPSFixType { get; set; }
public string Serial { get; set; }
public string HardwareVersion { get; set; }
public string FirmwareVersion { get; set; }
public string Relay1 { get; set; }
public string Relay2 { get; set; }
public string Relay3 { get; set; }
public string Ign { get; set; }
public string Doors { get; set; }
public string Input1 { get; set; }
public string Input2 { get; set; }
public string Out1 { get; set; }
public string Out2 { get; set; }
public int V12 { get; set; }
public int VBat { get; set; }
【问题讨论】:
-
免责声明 - 我是您引用的 //build 视频的共同作者之一 - 实际上没有“推荐”的方法来存储遥测数据。我们展示的用于存储遥测数据的是一个特定的建模案例,它基于我们处理过的一些实际解决方案,特定于 DocumentDB 等文档数据库(它可能适用于您的特定案例,也可能不适用)。还有其他建模方法,甚至是不同的数据库引擎类型。
-
嘿,戴夫,感谢您的回复 :) 是的,今天头脑风暴,发现了这个好视频,它给了我另一个选择。在 SQL 中一切正常,只是长期关注
-
很高兴你喜欢它 - 谢谢。 :) 如果它给了你一些新的思考,那么我认为它是成功的。
-
是的,我唯一担心的是为每个事件创建一个文档 ~ 每台设备每 5 分钟创建一个文档。将来可能会更改为每秒基准数:/ 需要考虑很多。
-
所以我认为我的 2 个选项是每个事件 1 个文档(可以是每秒:/)或每个时间段 1 个文档(每小时 1 个)。数据完全不同 - 纬度、经度、时间、#sats、HDOP 等。每台设备每秒创建一个文档的缺点是什么?成本/性能?如果是这样,我将在每个时间段(一小时或一天)的每个设备上制作一个文档。
标签: azure azure-cosmosdb document-database telemetry nosql