实时数据馈送 + NodeJS 和 MongoDB
想听听您对我解决问题的设计和技术选择的看法。
我从通过微控制器连接到速度传感器的计算机串行端口获取连续数据馈送(速度值 V)(每 30 秒发送一次值)。
我想做两件事:
- 将 V 和时间戳存储到 MongoDB
- 将此速度提供给网页并绘制图表。
存储 V 和时间戳用于处理此数据并计算一些指标(非实时)。
我选择 Mongo,因为这是我为应用程序的其余部分(网络应用程序)所做的选择 (架构较少,json,速度日志的上限集合,实时事物...)
我计划使用nodejs和spawn(cat / dev / ttyS0)来获取我的数据源, 然后,我可以将其存储到本地 MongoDB 并通过 http 服务器提供服务。
我刚刚发现 https://github.com/voodootikigod/node-serialport 可以更强大比我的产卵(猫...)
你会做同样的事情吗?
并且,如何将本地 MongoDB 速度集合与远程 MongoDB 数据库同步?
感谢您的帮助和想法!
PS:我有 3 台机器,3 个提要,带有 3 个不同的串行端口和 3 个节点服务器/本地 MongoDB...
would like to have your opinion about my design and technological choices to solve a problem.
I'm getting a continuos data feed (a speed value V) from a serial port of a computer connected to a speed sensor through a microcontroller (that sends the value each 30 seconds).
I want to do 2 things :
- store V and a timestamp to a MongoDB
- serve this speed to a webpage and draw a chart.
Storing V and timestamp is for processing this data and computing few metrics (not in realtime).
I choose Mongo as it's the choice I made for the rest of the app (web app)
(schema less, json, capped collections for my speed logs, realtime things ...)
I'm planning to go with nodejs and a spawn(cat /dev/ttyS0) to get my data feed,
then, I can store it to a local MongoDB and serving it through an http server.
I just found https://github.com/voodootikigod/node-serialport that can be more powerful than my spawn (cat ...)
Would you do the same thing?
And, how would you sync the local MongoDB speed collection with a distant MongoDB database ?
Thanks for your help and ideas !
PS: I have 3 machines, 3 feeds with 3 different serial ports and 3 node servers / Local MongoDBs...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
圣托莱多!
很明显你的设置会起作用。但仅仅在一天 24 小时内收集和存储大约 8640 个数据点就显得太过分了。您确定要安装和维护所有支持软件吗?然后照顾(或培训操作员照顾)那个
垃圾?软件?当您继续前进时,谁将继承您的纸牌屋?系统?我承认我不久前启动了 rasslin' (sp?) 串行通信1,但我想知道为什么它不是一个 200 行的用户程序,可能在后台运行。2
那么:你为什么需要这么多东西?
1 早在这一切 现代 froo-fooraw 出现之前,Sonny就已经开始了。 <黑客> 他们之间要步行二十五英里,穿过十英尺厚的熊出没的积雪,然后我们拿着火把在骆驼粪板上写下我们的楔形文字作业,不知道。哎呀,那个山洞有些潮湿啊!在那些日子里,一片腐臭的骆驼肝是上帝的恩赐,我们非常幸运能得到它,周六的庆祝活动意味着与小浣熊独处十分钟(嘿,看着它们 牙齿,甜心!)然后快速地敲响了和平管。
2 当每日蒸汽中断时,您的备用计划是什么?
Holy Toledo!
It's clear your setup will work. But it's huge overkill just to collect and store maybe 8640 data points over a 24-hour day. Are you sure you want to undertake to install and maintain all of that support software? And then babysit (or train an operator to babysit) that
crap?software? And when you move on, well, who's going to inherit yourhouse of cards?system?I admit I started rasslin' (sp?) serial comm a while ago1 but I wonder why it's not a 200-line user program, maybe running in the background.2
So: How come you need all that stuff?
1 Long before all this <snicker> modern froo-fooraw, Sonny <hack> <hack> <ptui!> between them twenty-five-mile walks to school through ten feet of bear-infested snow, after we scratched our cuneiform homework on camel-dung tablets by torchlight, dontcha' know. Man, that cave was some humid! In them days, a slice of rancid camel liver was a treat by God and we was damned lucky to get it and a Saturday celebration meant ten minutes alone with the baby raccoon (hey, watch them teeth, Sweetheart!) and a quick hit off the peace pipe.
2 And what's your backup plan when the daily steam outage comes along?