简体   繁体   English

监控服务MongoDB架构设计

[英]Monitoring Service MongoDB Schema Design

I have 1000+ streaming audio devices deployed around the world. 我在全球部署了1000多个流音频设备。 All of which currently check in with the factory monitoring service about every 15 minutes. 当前所有这些都大约每15分钟通过工厂监控服务进行一次检查。 I'm rolling my own monitoring service and will be storing the status updates with mongo. 我正在推出自己的监视服务,并将使用mongo存储状态更新。

Question: 题:

What would be a better design schema: 什么是更好的设计方案:

1) One massive collection named device_updates . 1)一个名为device_updates庞大集合。 Where all the status update document would include a device serial_number key? 所有状态更新文档将在哪里包含设备serial_number密钥?

2) 1000+ collections each named with the devices serial number, ie: 65FE9 , with the devices status updates siloed in their own collection If going this route I would cap the collections at about 2000 status update documents. 2)1000多个集合,每个集合使用设备序列号命名,即: 65FE9 ,设备状态更新65FE9在其自己的集合中。如果按照这种方式,我会将集合的上限限制在2000个状态更新文档中。

Both would need to be indexed by the created_at date key. 两者都需要由created_at日期键索引。

Any ideas on which would be better performance wise? 有什么想法可以更好地提高性能吗? Or any thoughts on what would be the preferred method? 或对首选方法有任何想法?

Thanks! 谢谢!

I would definitely go for one massive collection , since all the documents are of the same type . 我肯定会去收集大量的东西 ,因为所有文件都是同一类型

As a general rule, think of a collection in MongoDB as a set of homogeneous documents . 通常,将MongoDB中的集合视为一组同类文档 Having just one collection, moreover, makes it much easier to scale out horizontally (ie, by use of shards ), by using for example the serial_number as the shard key. 此外,仅使用一个集合,例如通过使用serial_number作为分片键,就可以更轻松地水平扩展(即,通过使用分 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM