存储高频、周期性时间序列数据的最佳方式?

Best way to store high frequency, periodic time-series data?

我已经为一个 nodejs 项目创建了一个 MVP,以下是与我要问的问题相关的一些特性:

1-应用程序有一个带有 CRUD 操作的 IP 地址列表。 2-应用程序将每隔 5 秒对每个 IP 地址执行一次 ping 操作。 3- 并针对每个 IP 地址显示其状态,即存活或死亡以及存活时间

我在库 net-ping、express、mongo 和 angular 的帮助下在 nodejs 上创建了一个有效的 MVP。现在我有一个新功能请求是:

"to calculate the round trip time(latency) for each ping that is generated for each IP address and populate a bar chart or any type of chart that will display the RTT(latency) history(1 months-1 year) of every connection"

我需要将每个 ping 的响应存储在数据库中,假设最好的情况是,如果我将存储的每个文档的大小为 0.5 kb,那么每天将存储 9.5MB 数据,285MB每个月和每年 3.4GB 的单个 IP 地址,我将在我的应用程序中有 100-200 个 IP 地址。

考虑到应用程序可以扩展,最适合我的要求的最佳解决方案(包括付费解决方案)是什么?

时间序列数据需要从数据库的角度进行特殊处理,因为它们从容量、查询性能、read/write优化目标等方面对传统数据库管理提出了挑战

我不建议您将这些数据存储在传统的 RDBMS 或 object/document 数据库中。

最好的选择是使用专门的时间序列数据库引擎,例如 InfluxDB,它可以支持下采样(聚合)和原始数据保留规则

所以我在阅读 this 后更改了时间序列数据的模式设计,这大大减少了我计算大小的数字

以前的架构如下所示:

{
  timestamp: ISODate("2013-10-10T23:06:37.000Z"),
  type: "Latency",
  value: 1000000
},
{
  timestamp: ISODate("2013-10-10T23:06:38.000Z"),
  type: "Latency",
  value: 15000000
}
Size of each document: 0.22kb
number of document created in an hour= 720
size of data generated in an hour=0.22*720 = 158.4kb
size of data generated by one IP address in a day= 158 *24 = 3.7MB

由于下一个 time_Stamp 只是从前一个增量 5 秒,因此可以优化架构以减少冗余数据。 新架构如下所示:

{
  timestamp_hour: ISODate("2013-10-10T23:06:00.000Z"),// will contain hours
  type: “Latency”,
  values: {//will contain data for all pings in the specific hour
    0: 999999,
    …
    37: 1000000,
    38: 1500000,
    … 
    720: 2000000
  }
}
Size of each document: 0.5kb
number of document created in an hour= 1
size of data generated in an hour= 0.5kb
size of data generated by one IP address in a day= 0.5 *24 = 12kb

所以我假设数据的大小将不再是一个问题,虽然对于在这种情况下应该使用哪种类型的存储以确保最佳性能存在争论,但我相信mongoDB 就我而言。