简体   繁体   English

数据优化-用于RESTful API的MongoDB和PHP

[英]Optimization of data - MongoDB and PHP for a RESTful API

This is more about an architectural decision for which I'm currently neither an expert in data storage or retrieval, specifically for MongoDB. 这更多是关于一个架构决策,我目前还不是该决策的数据存储或检索专家,尤其是MongoDB。

I currently have a RESTful API built in PHP-Slim framework, and have external devices submitting POST requests every second. 我目前有一个使用PHP-Slim框架构建的RESTful API,并且外部设备每秒提交一次POST请求。 For scalability, imagine if I had 100 devices, so 100 requests per second to process. 为了实现可伸缩性,想象一下如果我有100个设备,那么每秒要处理100个请求。

Each device submits 3 separate voltages - volt_a, volt_b, volt_c along with a device_id and time stamp, which gets stored as a single document. 每个设备提交3个单独的电压-volt_a,volt_b,volt_c以及device_id和时间戳,这些电压作为单个文档存储。 Now every time I run an aggregation pipeline, I need to $project the average voltage for every document, every time. 现在,每次运行聚合管道时,我都需要$project每次$project平均电压。

My question is, as I'm performing large aggregation queries over a large number of documents (for example, 1 hours data so 3600 documents) would it be better to just to calculate and store the average voltage in my POST method in PHP, as opposed to having to keep projecting it which impacts the aggregation performance? 我的问题是,由于我正在对大量文档(例如1小时数据,因此有3600个文档)执行大型聚合查询,因此最好只计算并存储PHP中POST方法中的平均电压,因为相对于必须不断预测会影响聚合性能的因素吗?

最初的问题本质上是从理论上提出的,但是为了获得进一步的了解,我将必须同时实现这两种方法并测量这两种方法的性能以获得满意的答案。

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

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